Skip to content

Commit eedb7c7

Browse files
committed
[layout][server] composer -> layout in getprint
1 parent 3df284f commit eedb7c7

File tree

21 files changed

+228
-242
lines changed

21 files changed

+228
-242
lines changed

src/server/services/wms/qgswmsrenderer.cpp

Lines changed: 199 additions & 229 deletions
Large diffs are not rendered by default.

src/server/services/wms/qgswmsrenderer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
class QgsCapabilitiesCache;
3333
class QgsCoordinateReferenceSystem;
34-
class QgsComposition;
34+
class QgsPrintLayout;
3535
class QgsConfigParser;
3636
class QgsFeature;
3737
class QgsFeatureRenderer;
@@ -274,8 +274,8 @@ namespace QgsWms
274274
//! Gets layer search rectangle (depending on request parameter, layer type, map and layer crs)
275275
QgsRectangle featureInfoSearchRect( QgsVectorLayer *ml, const QgsMapSettings &ms, const QgsRenderContext &rct, const QgsPointXY &infoPoint ) const;
276276

277-
//! configure the composition for the GetPrint request
278-
bool configureComposition( QgsComposition *c, const QgsMapSettings &mapSettings );
277+
//! configure the print layout for the GetPrint request
278+
bool configurePrintLayout( QgsPrintLayout *c, const QgsMapSettings &mapSettings );
279279

280280
//! Creates external WMS layer. Caller takes ownership
281281
QgsMapLayer *createExternalWMSLayer( const QString &externalLayerId ) const;

tests/src/python/qgis_wrapped_server.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
1111
?MAP=/path/to/projects.qgs&SERVICE=XYZ&X=1&Y=0&Z=1&LAYERS=world
1212
13+
Note that multi threading in QGIS server is not officially supported and
14+
it is not supposed to work in any case
15+
16+
Set MULTITHREADING environment varialbe to 1 to activate.
17+
1318
1419
For testing purposes, HTTP Basic can be enabled by setting the following
1520
environment variables:
@@ -188,7 +193,10 @@ class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
188193

189194

190195
if __name__ == '__main__':
191-
server = ThreadedHTTPServer((QGIS_SERVER_HOST, QGIS_SERVER_PORT), Handler)
196+
if os.environ.get('MULTITHREADING') == '1':
197+
server = ThreadedHTTPServer((QGIS_SERVER_HOST, QGIS_SERVER_PORT), Handler)
198+
else:
199+
server = HTTPServer((QGIS_SERVER_HOST, QGIS_SERVER_PORT), Handler)
192200
if https:
193201
server.socket = ssl.wrap_socket(server.socket,
194202
certfile=QGIS_SERVER_PKI_CERTIFICATE,

tests/src/python/test_qgsserver.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- coding: utf-8 -*-
22
"""QGIS Unit tests for QgsServer.
33
4+
Set the env var NO_ENCODED_OUTPUT to disable printing the base64 encoded image diff
5+
46
FIXME: keep here only generic server tests and move specific services
57
tests to test_qgsserver_<service>.py
68
@@ -189,17 +191,23 @@ def _img_diff_error(self, response, headers, image, max_diff=100, max_size_diff=
189191

190192
with open(os.path.join(tempfile.gettempdir(), image + "_result.png"), "rb") as rendered_file:
191193
encoded_rendered_file = base64.b64encode(rendered_file.read())
192-
message = "Image is wrong\n%s\nImage:\necho '%s' | base64 -d >%s/%s_result.png" % (
193-
report, encoded_rendered_file.strip().decode('utf8'), tempfile.gettempdir(), image
194-
)
194+
if os.environ.get('NO_ENCODED_OUTPUT'):
195+
message = "Image is wrong\: rendered file %s/%s_result.png" % (tempfile.gettempdir(), image)
196+
else:
197+
message = "Image is wrong\n%s\nImage:\necho '%s' | base64 -d >%s/%s_result.png" % (
198+
report, encoded_rendered_file.strip().decode('utf8'), tempfile.gettempdir(), image
199+
)
195200

196201
# If the failure is in image sizes the diff file will not exists.
197202
if os.path.exists(os.path.join(tempfile.gettempdir(), image + "_result_diff.png")):
198203
with open(os.path.join(tempfile.gettempdir(), image + "_result_diff.png"), "rb") as diff_file:
199-
encoded_diff_file = base64.b64encode(diff_file.read())
200-
message += "\nDiff:\necho '%s' | base64 -d > %s/%s_result_diff.png" % (
201-
encoded_diff_file.strip().decode('utf8'), tempfile.gettempdir(), image
202-
)
204+
if os.environ.get('NO_ENCODED_OUTPUT'):
205+
message = "Image is wrong\: diff file %s/%s_result_diff.png" % (tempfile.gettempdir(), image)
206+
else:
207+
encoded_diff_file = base64.b64encode(diff_file.read())
208+
message += "\nDiff:\necho '%s' | base64 -d > %s/%s_result_diff.png" % (
209+
encoded_diff_file.strip().decode('utf8'), tempfile.gettempdir(), image
210+
)
203211

204212
self.assertTrue(test, message)
205213

tests/src/python/test_qgsserver_wms_getprint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
2-
"""QGIS Unit tests for QgsServer WMS.
2+
"""QGIS Unit tests for QgsServer WMS GetPrint.
33
4-
From build dir, run: ctest -R PyQgsServerWMS -V
4+
From build dir, run: ctest -R PyQgsServerWMSGetPrint -V
55
66
77
.. note:: This program is free software; you can redistribute it and/or modify
0 Bytes
Loading
28.9 KB
Loading
938 KB
Loading
2.75 KB
Loading
2.68 KB
Loading

0 commit comments

Comments
 (0)