Skip to content

Commit 34009d3

Browse files
committedSep 27, 2018
[Tests][Server] Add test for WMS SLD parameter and move SLD_BODY test
1 parent c15f05b commit 34009d3

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
 

‎tests/src/python/test_qgsserver_wms_getmap.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,76 @@ def test_wms_getmap_annotations(self):
11091109
self._img_diff_error(r, h, "WMS_GetMap_Annotations")
11101110

11111111
def test_wms_getmap_sld(self):
1112+
import socketserver
1113+
import threading
1114+
import http.server
1115+
1116+
# Bring up a simple HTTP server
1117+
os.chdir(unitTestDataPath() + '')
1118+
handler = http.server.SimpleHTTPRequestHandler
1119+
1120+
httpd = socketserver.TCPServer(('localhost', 0), handler)
1121+
port = httpd.server_address[1]
1122+
1123+
httpd_thread = threading.Thread(target=httpd.serve_forever)
1124+
httpd_thread.setDaemon(True)
1125+
httpd_thread.start()
1126+
1127+
qs = "?" + "&".join(["%s=%s" % i for i in list({
1128+
"MAP": urllib.parse.quote(self.projectPath),
1129+
"SERVICE": "WMS",
1130+
"VERSION": "1.1.1",
1131+
"REQUEST": "GetMap",
1132+
"LAYERS": "Country,db_point",
1133+
"STYLES": "",
1134+
"FORMAT": "image/png",
1135+
"BBOX": "-16817707,-4710778,5696513,14587125",
1136+
"HEIGHT": "500",
1137+
"WIDTH": "500",
1138+
"CRS": "EPSG:3857"
1139+
}.items())])
1140+
1141+
r, h = self._result(self._execute_request(qs))
1142+
self._img_diff_error(r, h, "WMS_GetMap_SLDRestored")
1143+
1144+
qs = "?" + "&".join(["%s=%s" % i for i in list({
1145+
"MAP": urllib.parse.quote(self.projectPath),
1146+
"REQUEST": "GetMap",
1147+
"VERSION": "1.1.1",
1148+
"SERVICE": "WMS",
1149+
"SLD": "http://localhost:" + str(port) + "/qgis_local_server/db_point.sld",
1150+
"BBOX": "-16817707,-4710778,5696513,14587125",
1151+
"WIDTH": "500",
1152+
"HEIGHT": "500",
1153+
"LAYERS": "db_point",
1154+
"STYLES": "",
1155+
"FORMAT": "image/png",
1156+
"CRS": "EPSG:3857"
1157+
}.items())])
1158+
1159+
r, h = self._result(self._execute_request(qs))
1160+
self._img_diff_error(r, h, "WMS_GetMap_SLD")
1161+
1162+
qs = "?" + "&".join(["%s=%s" % i for i in list({
1163+
"MAP": urllib.parse.quote(self.projectPath),
1164+
"SERVICE": "WMS",
1165+
"VERSION": "1.1.1",
1166+
"REQUEST": "GetMap",
1167+
"LAYERS": "Country,db_point",
1168+
"STYLES": "",
1169+
"FORMAT": "image/png",
1170+
"BBOX": "-16817707,-4710778,5696513,14587125",
1171+
"HEIGHT": "500",
1172+
"WIDTH": "500",
1173+
"CRS": "EPSG:3857"
1174+
}.items())])
1175+
1176+
r, h = self._result(self._execute_request(qs))
1177+
self._img_diff_error(r, h, "WMS_GetMap_SLDRestored")
1178+
1179+
httpd.server_close()
1180+
1181+
def test_wms_getmap_sld_body(self):
11121182
qs = "?" + "&".join(["%s=%s" % i for i in list({
11131183
"MAP": urllib.parse.quote(self.projectPath),
11141184
"SERVICE": "WMS",
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ogc="http://www.opengis.net/ogc" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" version="1.1.0" xmlns:se="http://www.opengis.net/se" xmlns:xlink="http://www.w3.org/1999/xlink">
3+
<NamedLayer>
4+
<se:Name>db_point</se:Name>
5+
<UserStyle>
6+
<se:Name>db_point_style</se:Name>
7+
<se:FeatureTypeStyle>
8+
<se:Rule>
9+
<se:Name>Single symbol</se:Name>
10+
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
11+
<ogc:PropertyIsEqualTo>
12+
<ogc:PropertyName>gid</ogc:PropertyName>
13+
<ogc:Literal>1</ogc:Literal>
14+
</ogc:PropertyIsEqualTo>
15+
</ogc:Filter>
16+
<se:PointSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
17+
<se:Graphic>
18+
<se:Mark>
19+
<se:WellKnownName>square</se:WellKnownName>
20+
<se:Fill>
21+
<se:SvgParameter name="fill">5e86a1</se:SvgParameter>
22+
</se:Fill>
23+
<se:Stroke>
24+
<se:SvgParameter name="stroke">000000</se:SvgParameter>
25+
</se:Stroke>
26+
</se:Mark>
27+
<se:Size>0.007</se:Size>
28+
</se:Graphic>
29+
</se:PointSymbolizer>
30+
</se:Rule>
31+
</se:FeatureTypeStyle>
32+
</UserStyle>
33+
</NamedLayer>
34+
</StyledLayerDescriptor>

0 commit comments

Comments
 (0)
Please sign in to comment.