1 | <?xml version="1.0"?> |
---|
2 | |
---|
3 | <?python |
---|
4 | |
---|
5 | from cows.pylons.genshi_util import RenameElementFilter |
---|
6 | from genshi import QName |
---|
7 | import webhelpers as h |
---|
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 | <Layer py:def="markupLayer(ds)" queryable="${int(ds.queryable)}"> |
---|
41 | <Name py:content="ds.identifier"/> |
---|
42 | <Title py:content="ds.titles[0]"/> |
---|
43 | <Abstract py:if="len(ds.abstracts)>0" py:content="ds.abstracts[0]"/> |
---|
44 | <CRS py:for="crs in ds.CRSs" py:content="crs"/> |
---|
45 | <?python exBBox = ds.wgs84BoundingBoxes[0] ?> |
---|
46 | <EX_GeographicBoundingBox> |
---|
47 | <westBoundLongitude py:content="exBBox.lowerCorner[0]"/> |
---|
48 | <eastBoundLongitude py:content="exBBox.upperCorner[0]"/> |
---|
49 | <southBoundLatitude py:content="exBBox.lowerCorner[1]"/> |
---|
50 | <northBoundLatitude py:content="exBBox.upperCorner[1]"/> |
---|
51 | </EX_GeographicBoundingBox> |
---|
52 | |
---|
53 | <py:for each="bb in ds.boundingBoxes"> |
---|
54 | <BoundingBox CRS="${bb.crs}" |
---|
55 | minx="${'%.2f'%bb.lowerCorner[0]}" |
---|
56 | miny="${'%.2f'%bb.lowerCorner[1]}" |
---|
57 | maxx="${'%.2f'%bb.upperCorner[0]}" |
---|
58 | maxy="${'%.2f'%bb.upperCorner[1]}"/> |
---|
59 | </py:for> |
---|
60 | |
---|
61 | <!--!TODO Attribution from metadata --> |
---|
62 | <!--!TODO AuthorityURL from metadata --> |
---|
63 | <!--!TODO FeatureListURL from metadata --> |
---|
64 | <!--!TODO Identifier from metadata --> |
---|
65 | <!--!TODO DataURL from metadata --> |
---|
66 | <!--!TODO MetadataURL from metadata --> |
---|
67 | |
---|
68 | <!--!NOTE: this is an ad-hoc implementation not using the ows_common.model classes |
---|
69 | TODO: fixme --> |
---|
70 | <!-- TODO ScaleHint --> |
---|
71 | |
---|
72 | <Dimension py:for="d_n, d in ds.dimensions.iteritems()" |
---|
73 | name="${d_n}" units="${d.valuesUnit}" |
---|
74 | unitSymbol="${d.unitSymbol}" |
---|
75 | default="${d.defaultValue}" |
---|
76 | py:content="','.join(d.possibleValues.allowedValues)"/> |
---|
77 | <!--! nearestValue="${int(d.nearestValue)}" --> |
---|
78 | <Style> |
---|
79 | <Name>default</Name> |
---|
80 | <Title>Default</Title> |
---|
81 | <LegendURL width="${ds.legendSize[0]}" height="${ds.legendSize[1]}"> |
---|
82 | <Format py:for="f in ds.legendFormats" py:content="f"/> |
---|
83 | <OnlineResource xlink:type="simple" xlink:href="${h.url_for(qualified=True, action='index')}?request=GetLegend&layers=${ds.identifier}"/> |
---|
84 | </LegendURL> |
---|
85 | </Style> |
---|
86 | |
---|
87 | |
---|
88 | </Layer> |
---|
89 | |
---|
90 | <!--! ====================================================================== --> |
---|
91 | |
---|
92 | |
---|
93 | <Service py:with="sm=c.capabilities; si=c.capabilities.serviceIdentification"> |
---|
94 | <Name>WMS</Name> |
---|
95 | <Title py:content="si.titles[0]"/> |
---|
96 | <Abstract py:if="len(si.abstracts)>0" py:content="si.abstracts[0]"/> |
---|
97 | <KeywordList> |
---|
98 | <Keyword py:for="kw in si.keywords" |
---|
99 | py:content="kw"/> |
---|
100 | </KeywordList> |
---|
101 | <OnlineResource xlink:type="simple" xlink:href="${h.url_for(qualified=True, action='index')}?"/> |
---|
102 | |
---|
103 | <ContactInformation py:if="sm.serviceProvider is not None" |
---|
104 | py:with="rp=sm.serviceProvider.serviceContact"> |
---|
105 | <ContactPersonPrimary> |
---|
106 | <ContactPerson py:if="rp is not None" py:content="rp.individualName"/> |
---|
107 | <ContactOrganization py:content="sm.serviceProvider.providerName"/> |
---|
108 | </ContactPersonPrimary> |
---|
109 | <ContactPosition py:content="rp.positionName"/> |
---|
110 | |
---|
111 | <py:with vars="cn=rp.contactInfo" py:if="rp.contactInfo is not None"> |
---|
112 | <ContactAddress py:if="cn.address is not None"> |
---|
113 | <AddressType>postal</AddressType> |
---|
114 | <Address> |
---|
115 | <py:for each="d in cn.address.deliveryPoints">${d}</py:for> |
---|
116 | </Address> |
---|
117 | <City py:content="cn.address.city"/> |
---|
118 | <StateOrProvince py:content="cn.address.administrativeArea"/> |
---|
119 | <PostCode py:content="cn.address.postalCode"/> |
---|
120 | <Country py:content="cn.address.country"/> |
---|
121 | </ContactAddress> |
---|
122 | <ContactVoiceTelephone py:if="cn.phone is not None" |
---|
123 | py:content="cn.phone.voice"/> |
---|
124 | <ContactFacsimileTelephone py:if="cn.phone is not None" |
---|
125 | py:content="cn.phone.facsimile"/> |
---|
126 | <ContactElectronicMailAddress py:if="cn.address is not None" |
---|
127 | py:content="cn.address.electronicMailAddress"/> |
---|
128 | </py:with> |
---|
129 | </ContactInformation> |
---|
130 | |
---|
131 | <Fees py:content="si.fees"/> |
---|
132 | <AccessConstraints py:content="si.accessConstraints"/> |
---|
133 | |
---|
134 | <!--!TODO: These are hardcoded for Jon Blower's WMS->KML service. Make generic.--> |
---|
135 | <LayerLimit>1</LayerLimit> |
---|
136 | <MaxWidth>640</MaxWidth> |
---|
137 | <MaxHeight>640</MaxHeight> |
---|
138 | |
---|
139 | </Service> |
---|
140 | <!--! These fields are represented in ows_common as service constraints --> |
---|
141 | <Capability py:with="sm=c.capabilities; om=sm.operationsMetadata"> |
---|
142 | <py:if test="om is not None"> |
---|
143 | <?python |
---|
144 | ops = ['GetCapabilities', 'GetMap', 'GetFeatureInfo'] |
---|
145 | eops = [x for x in om.operationDict.keys() if x not in ops] |
---|
146 | ?> |
---|
147 | <Request> |
---|
148 | <py:for each="opName in ops" py:if="opName in om.operationDict.keys()"> |
---|
149 | <span py:content="markupOperation(opName, om.operationDict[opName])" py:strip="True"/> |
---|
150 | </py:for> |
---|
151 | <py:for each="opName in ops" py:if="opName in om.operationDict.keys()"> |
---|
152 | <?python exceptions = om.operationDict[opName].parameters.get('ExceptionFormat') ?> |
---|
153 | <Exception py:if="exceptions is not None"> |
---|
154 | <Format py:for="e in exceptions.possibleValues.allowedValues" |
---|
155 | py:content="e"/> |
---|
156 | </Exception> |
---|
157 | </py:for> |
---|
158 | </Request> |
---|
159 | <_ExtendedCapabilities> |
---|
160 | <Request> |
---|
161 | <py:for each="opName in eops"> |
---|
162 | <span py:content="markupOperation(opName, om.operationDict[opName])" py:strip="True"/> |
---|
163 | </py:for> |
---|
164 | <py:for each="opName in eops"> |
---|
165 | <?python exceptions = om.operationDict[opName].parameters.get('ExceptionFormat') ?> |
---|
166 | <Exception py:if="exceptions is not None"> |
---|
167 | <Format py:for="e in exceptions.possibleValues.allowedValues" |
---|
168 | py:content="e"/> |
---|
169 | </Exception> |
---|
170 | </py:for> |
---|
171 | </Request> |
---|
172 | </_ExtendedCapabilities> |
---|
173 | </py:if> |
---|
174 | |
---|
175 | <!--!TODO: capability exceptions --> |
---|
176 | <Exception><Format>text/xml</Format></Exception> |
---|
177 | |
---|
178 | <Layer py:if="sm.contents is not None"> |
---|
179 | <Title>Contents</Title> |
---|
180 | <Layer py:for="ds in sm.contents.datasetSummaries" |
---|
181 | py:replace="markupLayer(ds)"> |
---|
182 | </Layer> |
---|
183 | </Layer> |
---|
184 | </Capability> |
---|
185 | </WMS_Capabilities> |
---|