1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <?python |
---|
3 | """ |
---|
4 | Implements WCS capabilities v1.1.0 based on the ows_common model. |
---|
5 | |
---|
6 | Assumes ows_common.ServiceMetadata() object at c.service_metadata. |
---|
7 | |
---|
8 | """ |
---|
9 | try: #python 2.5 |
---|
10 | from xml.etree import ElementTree as etree |
---|
11 | except ImportError: |
---|
12 | try: |
---|
13 | # if you've installed it yourself it comes this way |
---|
14 | import ElementTree as etree |
---|
15 | except ImportError: |
---|
16 | # if you've egged it this is the way it comes |
---|
17 | from elementtree import ElementTree as etree |
---|
18 | |
---|
19 | |
---|
20 | def get_ops(op, tag_name): |
---|
21 | """ |
---|
22 | Uses element tree to define the operations section. |
---|
23 | |
---|
24 | """ |
---|
25 | newelement=etree.Element("test") |
---|
26 | newelement.tag = tag_name |
---|
27 | |
---|
28 | http=etree.Element("HTTP") |
---|
29 | if op.get is not None: |
---|
30 | getelem=etree.Element("Get") |
---|
31 | oR=etree.Element("OnlineResource") |
---|
32 | oR.attrib['xlink:href'] = op.get.href+'?' |
---|
33 | oR.attrib['xlink:type'] = 'simple' |
---|
34 | getelem.append(oR) |
---|
35 | http.append(getelem) |
---|
36 | if op.post is not None: |
---|
37 | postelem=etree.Element("Post") |
---|
38 | oR=etree.Element("OnlineResource") |
---|
39 | oR.attrib['xlink:href'] = op.post.href+'?' |
---|
40 | oR.attrib['xlink:type'] = 'simple' |
---|
41 | postelem.append(oR) |
---|
42 | http.append(postelem) |
---|
43 | |
---|
44 | dcp=etree.Element("DCPType") |
---|
45 | dcp.append(http) |
---|
46 | newelement.append(dcp) |
---|
47 | return newelement |
---|
48 | |
---|
49 | ?> |
---|
50 | <WCS_Capabilities xmlns:py="http://purl.org/kid/ns#" xmlns="http://www.opengis.net/wcs" |
---|
51 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
---|
52 | xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" |
---|
53 | version="1.0.0"> |
---|
54 | |
---|
55 | |
---|
56 | <CoverageOfferingBrief py:def="coverageSummary(ds)"> |
---|
57 | <!--! coverageSummary comes from wcsDatasetSummary TODO --> |
---|
58 | <name py:if="ds.identifier is not None" py:content="ds.identifier"/> |
---|
59 | <label py:if="ds.titles is not None" py:content="ds.titles"/> |
---|
60 | <lonLatEnvelope py:for="bb in ds.boundingBoxes"> |
---|
61 | <gml:pos>${bb.lowerCorner[0]} ${bb.lowerCorner[1]}</gml:pos> |
---|
62 | <gml:pos>${bb.upperCorner[0]} ${bb.upperCorner[1]}</gml:pos> |
---|
63 | <gml:timePosition>${ds.timeLimits[0]}</gml:timePosition> |
---|
64 | <gml:timePosition>${ds.timeLimits[1]}</gml:timePosition> |
---|
65 | </lonLatEnvelope> |
---|
66 | <keywords> |
---|
67 | <keyword>NONE</keyword> |
---|
68 | </keywords> |
---|
69 | </CoverageOfferingBrief> |
---|
70 | |
---|
71 | |
---|
72 | <!--! Main body --> |
---|
73 | <?python |
---|
74 | sm = c.service_metadata |
---|
75 | si = c.service_metadata.serviceIdentification |
---|
76 | #manage flags to specify if only a section of the capabilities doc has been requested: |
---|
77 | servSection, capSection, cmSection=True, True, True |
---|
78 | |
---|
79 | if sm.sectionrequested == '/Service': |
---|
80 | capSection=False |
---|
81 | cmSection=False |
---|
82 | elif sm.sectionrequested == '/Capability': |
---|
83 | servSection=False |
---|
84 | cmSection=False |
---|
85 | elif sm.sectionrequested == '/ContentMetadata': |
---|
86 | servSection=False |
---|
87 | capSection=False |
---|
88 | |
---|
89 | |
---|
90 | ?> |
---|
91 | <!--***************************************--> |
---|
92 | <!--* Service *--> |
---|
93 | <!--***************************************--> |
---|
94 | <Service py:if="servSection is True"> |
---|
95 | <description py:if="len(si.abstracts)>0" py:content="si.abstracts[0]"/> |
---|
96 | <name>tba</name> |
---|
97 | <label py:content="si.titles[0]"/> |
---|
98 | <keywords> |
---|
99 | <keyword py:for="kw in si.keywords" |
---|
100 | py:content="kw"/> |
---|
101 | </keywords> |
---|
102 | <!--! <owcs:ServiceType>OCG WCS</owcs:ServiceType> --> |
---|
103 | <!--! <owcs:ServiceTypeVersion>1.1.0</owcs:ServiceTypeVersion> --> |
---|
104 | <responsibleParty py:if="sm.serviceProvider is not None"> |
---|
105 | <?python rp = sm.serviceProvider.serviceContact ?> |
---|
106 | <individualName py:if="rp is not None" py:content="rp.individualName"/> |
---|
107 | <organisationName py:content="sm.serviceProvider.providerName"/> |
---|
108 | <positionName py:content="rp.positionName"/> |
---|
109 | <?python cn = rp.contactInfo ?> |
---|
110 | <div py:if="cn is not None" py:strip="1"> |
---|
111 | <contactInfo> |
---|
112 | <phone> |
---|
113 | <voice py:if="cn.phone is not None" |
---|
114 | py:content="cn.phone.voice"/> |
---|
115 | <facsimile py:if="cn.phone is not None" |
---|
116 | py:content="cn.phone.facsimile"/> |
---|
117 | </phone> |
---|
118 | <address py:if="cn.address is not None"> |
---|
119 | <deliveryPoint py:for="d in cn.address.deliveryPoints" py:content="d"/> |
---|
120 | <city py:content="cn.address.city"/> |
---|
121 | <administrativeArea py:content="cn.address.administrativeArea"/> |
---|
122 | <postalCode py:content="cn.address.postalCode"/> |
---|
123 | <country py:content="cn.address.country"/> |
---|
124 | <electronicMailAddress py:if="cn.address is not None" |
---|
125 | py:content="cn.address.electronicMailAddress"/> |
---|
126 | </address> |
---|
127 | </contactInfo> |
---|
128 | </div> |
---|
129 | </responsibleParty> |
---|
130 | <fees py:content="si.fees"/> |
---|
131 | <accessConstraints py:content="si.accessConstraints"/> |
---|
132 | </Service> |
---|
133 | |
---|
134 | <!--***************************************--> |
---|
135 | <!--* Capability *--> |
---|
136 | <!--***************************************--> |
---|
137 | <?python om = sm.operationsMetadata ?> |
---|
138 | <Capability py:if="capSection is True"> |
---|
139 | <Request> |
---|
140 | <ops py:for="opName, op in om.operationDict.items()" |
---|
141 | py:content="get_ops(op, opName)" py:strip="1"/> |
---|
142 | </Request> |
---|
143 | |
---|
144 | <?python exceptions = op.parameters.get('ExceptionFormat') ?> |
---|
145 | <Exception> |
---|
146 | <Format>application/vnd.ogc.se_xml</Format> |
---|
147 | </Exception> |
---|
148 | <!--! <Layer py:replace="layer(sm.contents.datasetSummaries[0])"/> --> |
---|
149 | </Capability> |
---|
150 | <!--***************************************--> |
---|
151 | <!--* ContentMetadata *--> |
---|
152 | <!--***************************************--> |
---|
153 | <ContentMetadata py:if="cmSection is True"> |
---|
154 | <CoverageOfferingBrief py:for="ds in sm.contents.datasetSummaries[0].datasetSummaries" py:replace="coverageSummary(ds)"/> |
---|
155 | </ContentMetadata> |
---|
156 | </WCS_Capabilities> |
---|