Skip to content

Commit

Permalink
[layout][server] composer -> layout in getprint
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jan 10, 2018
1 parent 3df284f commit eedb7c7
Show file tree
Hide file tree
Showing 21 changed files with 228 additions and 242 deletions.
428 changes: 199 additions & 229 deletions src/server/services/wms/qgswmsrenderer.cpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/server/services/wms/qgswmsrenderer.h
Expand Up @@ -31,7 +31,7 @@

class QgsCapabilitiesCache;
class QgsCoordinateReferenceSystem;
class QgsComposition;
class QgsPrintLayout;
class QgsConfigParser;
class QgsFeature;
class QgsFeatureRenderer;
Expand Down Expand Up @@ -274,8 +274,8 @@ namespace QgsWms
//! Gets layer search rectangle (depending on request parameter, layer type, map and layer crs)
QgsRectangle featureInfoSearchRect( QgsVectorLayer *ml, const QgsMapSettings &ms, const QgsRenderContext &rct, const QgsPointXY &infoPoint ) const;

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

//! Creates external WMS layer. Caller takes ownership
QgsMapLayer *createExternalWMSLayer( const QString &externalLayerId ) const;
Expand Down
10 changes: 9 additions & 1 deletion tests/src/python/qgis_wrapped_server.py
Expand Up @@ -10,6 +10,11 @@
?MAP=/path/to/projects.qgs&SERVICE=XYZ&X=1&Y=0&Z=1&LAYERS=world
Note that multi threading in QGIS server is not officially supported and
it is not supposed to work in any case
Set MULTITHREADING environment varialbe to 1 to activate.
For testing purposes, HTTP Basic can be enabled by setting the following
environment variables:
Expand Down Expand Up @@ -188,7 +193,10 @@ class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):


if __name__ == '__main__':
server = ThreadedHTTPServer((QGIS_SERVER_HOST, QGIS_SERVER_PORT), Handler)
if os.environ.get('MULTITHREADING') == '1':
server = ThreadedHTTPServer((QGIS_SERVER_HOST, QGIS_SERVER_PORT), Handler)
else:
server = HTTPServer((QGIS_SERVER_HOST, QGIS_SERVER_PORT), Handler)
if https:
server.socket = ssl.wrap_socket(server.socket,
certfile=QGIS_SERVER_PKI_CERTIFICATE,
Expand Down
22 changes: 15 additions & 7 deletions tests/src/python/test_qgsserver.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""QGIS Unit tests for QgsServer.
Set the env var NO_ENCODED_OUTPUT to disable printing the base64 encoded image diff
FIXME: keep here only generic server tests and move specific services
tests to test_qgsserver_<service>.py
Expand Down Expand Up @@ -189,17 +191,23 @@ def _img_diff_error(self, response, headers, image, max_diff=100, max_size_diff=

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

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

self.assertTrue(test, message)

Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgsserver_wms_getprint.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""QGIS Unit tests for QgsServer WMS.
"""QGIS Unit tests for QgsServer WMS GetPrint.
From build dir, run: ctest -R PyQgsServerWMS -V
From build dir, run: ctest -R PyQgsServerWMSGetPrint -V
.. note:: This program is free software; you can redistribute it and/or modify
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit eedb7c7

Please sign in to comment.