Skip to content

Commit 43c1710

Browse files
committed
remove faux wms capabilities
1 parent 4e1f24e commit 43c1710

File tree

3 files changed

+63
-52
lines changed

3 files changed

+63
-52
lines changed

geoengine/workflow.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ def srs_to_projection(srs: str) -> ccrs.Projection:
220220

221221
wms = WebMapService(wms_url,
222222
version='1.3.0',
223-
xml=self.__faux_capabilities(wms_url, str(self), bbox),
224223
auth=Authentication(auth_delegate=session.requests_bearer_auth()),
225224
timeout=timeout)
226225

@@ -306,56 +305,6 @@ def wms_get_map_curl(self, bbox: QueryRectangle, colorizer_min_max: Tuple[float,
306305
headers = " -H ".join(headers)
307306
return command.format(method=wms_request.method, headers=headers, uri=wms_request.url)
308307

309-
@classmethod
310-
def __faux_capabilities(cls, wms_url: str, layer_name: str, bbox: QueryRectangle) -> str:
311-
'''Create an XML file with faux capabilities to list the layer with `layer_name`'''
312-
313-
return '''
314-
<WMS_Capabilities xmlns="http://www.opengis.net/wms" xmlns:sld="http://www.opengis.net/sld" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.3.0" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd">
315-
<Service>
316-
<Name>WMS</Name>
317-
<Title>Geo Engine WMS</Title>
318-
</Service>
319-
<Capability>
320-
<Request>
321-
<GetCapabilities>
322-
<Format>text/xml</Format>
323-
<DCPType>
324-
<HTTP>
325-
<Get>
326-
<OnlineResource xlink:href="{wms_url}"/>
327-
</Get>
328-
</HTTP>
329-
</DCPType>
330-
</GetCapabilities>
331-
<GetMap>
332-
<Format>image/png</Format>
333-
<DCPType>
334-
<HTTP>
335-
<Get>
336-
<OnlineResource xlink:href="{wms_url}"/>
337-
</Get>
338-
</HTTP>
339-
</DCPType>
340-
</GetMap>
341-
</Request>
342-
<Exception>
343-
<Format>XML</Format>
344-
<Format>INIMAGE</Format>
345-
<Format>BLANK</Format>
346-
</Exception>
347-
<Layer queryable="1">
348-
<Name>{layer_name}</Name>
349-
<Title>{layer_name}</Title>
350-
<CRS>{crs}</CRS>
351-
<BoundingBox CRS="EPSG:4326" minx="-90.0" miny="-180.0" maxx="90.0" maxy="180.0"/>
352-
</Layer>
353-
</Capability>
354-
</WMS_Capabilities>
355-
'''.format(wms_url=wms_url,
356-
layer_name=layer_name,
357-
crs=bbox.srs)
358-
359308
def plot_chart(self, bbox: QueryRectangle) -> VegaLite:
360309
'''
361310
Query a workflow and return the plot chart result as a vega plot
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<WMS_Capabilities xmlns="http://www.opengis.net/wms"
2+
xmlns:sld="http://www.opengis.net/sld"
3+
xmlns:xlink="http://www.w3.org/1999/xlink"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.3.0" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd">
5+
<Service>
6+
<Name>WMS</Name>
7+
<Title>Geo Engine WMS</Title>
8+
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost"/>
9+
</Service>
10+
<Capability>
11+
<Request>
12+
<GetCapabilities>
13+
<Format>text/xml</Format>
14+
<DCPType>
15+
<HTTP>
16+
<Get>
17+
<OnlineResource xlink:href="http://mock-instance/wms/5b9508a8-bd34-5a1c-acd6-75bb832d2d38"/>
18+
</Get>
19+
</HTTP>
20+
</DCPType>
21+
</GetCapabilities>
22+
<GetMap>
23+
<Format>image/png</Format>
24+
<DCPType>
25+
<HTTP>
26+
<Get>
27+
<OnlineResource xlink:href="http://mock-instance/wms/5b9508a8-bd34-5a1c-acd6-75bb832d2d38"/>
28+
</Get>
29+
</HTTP>
30+
</DCPType>
31+
</GetMap>
32+
</Request>
33+
<Exception>
34+
<Format>XML</Format>
35+
<Format>INIMAGE</Format>
36+
<Format>BLANK</Format>
37+
</Exception>
38+
<Layer queryable="1">
39+
<Name>5b9508a8-bd34-5a1c-acd6-75bb832d2d38</Name>
40+
<Title>Workflow 5b9508a8-bd34-5a1c-acd6-75bb832d2d38</Title>
41+
<EX_GeographicBoundingBox>
42+
<westBoundLongitude>-180</westBoundLongitude>
43+
<eastBoundLongitude>180</eastBoundLongitude>
44+
<southBoundLatitude>-90</southBoundLatitude>
45+
<northBoundLatitude>90</northBoundLatitude>
46+
</EX_GeographicBoundingBox>
47+
<BoundingBox CRS="EPSG:4326" minx="-90.0" miny="-180.0" maxx="90.0" maxy="180.0"/>
48+
</Layer>
49+
</Capability>
50+
</WMS_Capabilities>

tests/test_wms.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def test_ndvi(self):
5151
m.get('http://epsg.io/4326.gml?download', body=epsg4326_gml)
5252

5353
# Unfortunately, we need a separate library to catch the request from the WMS call
54+
with open("tests/responses/wms_capabilities.xml", "r", encoding="utf-8") as wms_capabilities:
55+
m.get(
56+
# pylint: disable=line-too-long
57+
'http://mock-instance/wms/5b9508a8-bd34-5a1c-acd6-75bb832d2d38?service=WMS&request=GetCapabilities&version=1.3.0',
58+
text=wms_capabilities.read())
59+
5460
with open("tests/responses/wms-ndvi.png", "rb") as wms_ndvi:
5561
responses.add(
5662
# pylint: disable=line-too-long
@@ -93,7 +99,7 @@ def test_ndvi(self):
9399
self.assertEqual(type(ax), cartopy.mpl.geoaxes.GeoAxesSubplot)
94100

95101
# Check requests from the mocker
96-
self.assertEqual(len(m.request_history), 4)
102+
self.assertEqual(len(m.request_history), 5)
97103

98104
workflow_request = m.request_history[1]
99105
self.assertEqual(workflow_request.method, "POST")
@@ -132,6 +138,12 @@ def test_ndvi_image(self):
132138
m.get('http://epsg.io/4326.gml?download', body=epsg4326_gml)
133139

134140
# Unfortunately, we need a separate library to catch the request from the WMS call
141+
with open("tests/responses/wms_capabilities.xml", "r", encoding="utf-8") as wms_capabilities:
142+
m.get(
143+
# pylint: disable=line-too-long
144+
'http://mock-instance/wms/5b9508a8-bd34-5a1c-acd6-75bb832d2d38?service=WMS&request=GetCapabilities&version=1.3.0',
145+
text=wms_capabilities.read())
146+
135147
m.get(
136148
# pylint: disable=line-too-long
137149
'http://mock-instance/wms/5b9508a8-bd34-5a1c-acd6-75bb832d2d38?service=WMS&version=1.3.0&request=GetMap&layers=5b9508a8-bd34-5a1c-acd6-75bb832d2d38&time=2014-04-01T12%3A00%3A00.000%2B00%3A00&crs=EPSG%3A4326&bbox=-90.0%2C-180.0%2C90.0%2C180.0&width=200&height=100&format=image%2Fpng&styles=custom%3A%7B%22type%22%3A+%22linearGradient%22%2C+%22breakpoints%22%3A+%5B%7B%22value%22%3A+0%2C+%22color%22%3A+%5B0%2C+0%2C+0%2C+255%5D%7D%2C+%7B%22value%22%3A+255%2C+%22color%22%3A+%5B255%2C+255%2C+255%2C+255%5D%7D%5D%2C+%22noDataColor%22%3A+%5B0%2C+0%2C+0%2C+0%5D%2C+%22defaultColor%22%3A+%5B0%2C+0%2C+0%2C+0%5D%7D',

0 commit comments

Comments
 (0)