Skip to content
Permalink
Browse files

[layout][server] composer -> layout in getprint

  • Loading branch information
elpaso committed Jan 10, 2018
1 parent 3df284f commit eedb7c795fa7a695b6737c384dcd45834ea2f6d5
Showing with 228 additions and 242 deletions.
  1. +199 −229 src/server/services/wms/qgswmsrenderer.cpp
  2. +3 −3 src/server/services/wms/qgswmsrenderer.h
  3. +9 −1 tests/src/python/qgis_wrapped_server.py
  4. +15 −7 tests/src/python/test_qgsserver.py
  5. +2 −2 tests/src/python/test_qgsserver_wms_getprint.py
  6. BIN tests/testdata/control_images/qgis_server/WMS_GetMap_Annotations/WMS_GetMap_Annotations.png
  7. BIN tests/testdata/control_images/qgis_server/WMS_GetMap_Mode_1bit/WMS_GetMap_Mode_1bit.png
  8. BIN tests/testdata/control_images/qgis_server/WMS_GetMap_StyleCustom/WMS_GetMap_StyleCustom.png
  9. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Basic/WMS_GetPrint_Basic.png
  10. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Grid/WMS_GetPrint_Grid.png
  11. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Highlight/WMS_GetPrint_Highlight.png
  12. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_LabelRemoved/WMS_GetPrint_LabelRemoved.png
  13. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_LabelUpdated/WMS_GetPrint_LabelUpdated.png
  14. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Legend/WMS_GetPrint_Legend.png
  15. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Opacity/WMS_GetPrint_Opacity.png
  16. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Rotation/WMS_GetPrint_Rotation.png
  17. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_SRS/WMS_GetPrint_SRS.png
  18. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Scale/WMS_GetPrint_Scale.png
  19. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Selection/WMS_GetPrint_Selection.png
  20. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_StyleCustom/WMS_GetPrint_StyleCustom.png
  21. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_StyleDefault/WMS_GetPrint_StyleDefault.png

Large diffs are not rendered by default.

@@ -31,7 +31,7 @@

class QgsCapabilitiesCache;
class QgsCoordinateReferenceSystem;
class QgsComposition;
class QgsPrintLayout;
class QgsConfigParser;
class QgsFeature;
class QgsFeatureRenderer;
@@ -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;
@@ -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:
@@ -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,
@@ -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
@@ -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)

@@ -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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit eedb7c7

Please sign in to comment.
You can’t perform that action at this time.