Skip to content
Permalink
Browse files

Merge pull request #8793 from elpaso/bugfix-20693-server-LAYERTITLESPACE

[server] Respect layer title space when rendering legends
  • Loading branch information
elpaso committed Jan 5, 2019
2 parents ed9c9b3 + 7d592a0 commit f075109d6a7840e2299aa2febd4d84c2123028bf
Showing with 46 additions and 7 deletions.
  1. +1 −0 src/core/qgslegendrenderer.cpp
  2. +6 −5 src/server/services/wms/qgswmsparameters.cpp
  3. +4 −0 tests/src/python/test_qgsserver.py
  4. +4 −0 tests/src/python/test_qgsserver_accesscontrol.py
  5. +3 −0 tests/src/python/test_qgsserver_accesscontrol_wms_getlegendgraphic.py
  6. +28 −2 tests/src/python/test_qgsserver_wms_getlegendgraphic.py
  7. BIN tests/testdata/control_images/qgis_server/WMS_GetLegendGraphic_BBox/WMS_GetLegendGraphic_BBox.png
  8. BIN tests/testdata/control_images/qgis_server/WMS_GetLegendGraphic_BBox2/WMS_GetLegendGraphic_BBox2.png
  9. BIN ...ta/control_images/qgis_server/WMS_GetLegendGraphic_Background/WMS_GetLegendGraphic_Background.png
  10. BIN ...ol_images/qgis_server/WMS_GetLegendGraphic_Background_Hex/WMS_GetLegendGraphic_Background_Hex.png
  11. BIN tests/testdata/control_images/qgis_server/WMS_GetLegendGraphic_Basic/WMS_GetLegendGraphic_Basic.png
  12. BIN ...stdata/control_images/qgis_server/WMS_GetLegendGraphic_BoxSpace/WMS_GetLegendGraphic_BoxSpace.png
  13. BIN ...ol_images/qgis_server/WMS_GetLegendGraphic_IconLabelSpace/WMS_GetLegendGraphic_IconLabelSpace.png
  14. BIN ...stdata/control_images/qgis_server/WMS_GetLegendGraphic_ItemFont/WMS_GetLegendGraphic_ItemFont.png
  15. BIN ...a/control_images/qgis_server/WMS_GetLegendGraphic_ItemFont/WMS_GetLegendGraphic_ItemFont_mask.png
  16. BIN ...data/control_images/qgis_server/WMS_GetLegendGraphic_LayerFont/WMS_GetLegendGraphic_LayerFont.png
  17. BIN ...control_images/qgis_server/WMS_GetLegendGraphic_LayerFont/WMS_GetLegendGraphic_LayerFont_mask.png
  18. BIN ...ta/control_images/qgis_server/WMS_GetLegendGraphic_LayerSpace/WMS_GetLegendGraphic_LayerSpace.png
  19. BIN ...ntrol_images/qgis_server/WMS_GetLegendGraphic_LayerSpace/WMS_GetLegendGraphic_LayerSpace_mask.png
  20. BIN ..._images/qgis_server/WMS_GetLegendGraphic_LayerTitleSpace/WMS_GetLegendGraphic_LayerTitleSpace.png
  21. BIN ...es/qgis_server/WMS_GetLegendGraphic_LayerTitleSpace/WMS_GetLegendGraphic_LayerTitleSpace_mask.png
  22. BIN ...mages/qgis_server/WMS_GetLegendGraphic_ShowFeatureCount/WMS_GetLegendGraphic_ShowFeatureCount.png
  23. BIN .../qgis_server/WMS_GetLegendGraphic_ShowFeatureCount/WMS_GetLegendGraphic_ShowFeatureCount_mask.png
  24. BIN ...ta/control_images/qgis_server/WMS_GetLegendGraphic_SymbolSize/WMS_GetLegendGraphic_SymbolSize.png
  25. BIN .../control_images/qgis_server/WMS_GetLegendGraphic_SymbolSpace/WMS_GetLegendGraphic_SymbolSpace.png
  26. BIN tests/testdata/control_images/qgis_server/WMS_GetLegendGraphic_rule0/WMS_GetLegendGraphic_rule0.png
  27. BIN tests/testdata/control_images/qgis_server/WMS_GetLegendGraphic_rule1/WMS_GetLegendGraphic_rule1.png
  28. BIN ..._images/qgis_server/WMS_GetLegendGraphic_rulelabel_false/WMS_GetLegendGraphic_rulelabel_false.png
  29. BIN ...es/qgis_server/WMS_GetLegendGraphic_rulelabel_false/WMS_GetLegendGraphic_rulelabel_false_mask.png
  30. BIN tests/testdata/control_images/qgis_server/WMS_GetLegendGraphic_test/WMS_GetLegendGraphic_test.png
  31. BIN .../testdata/control_images/qgis_server/WMS_GetLegendGraphic_test/WMS_GetLegendGraphic_test_mask.png
  32. BIN ..._server/WMS_GetLegendGraphic_test_layertitle_false/WMS_GetLegendGraphic_test_layertitle_false.png
  33. BIN ...ol_images/qgis_server_accesscontrol/WMS_GetLegendGraphic_Country/WMS_GetLegendGraphic_Country.png
  34. BIN ...ages/qgis_server_accesscontrol/WMS_GetLegendGraphic_Country/WMS_GetLegendGraphic_Country_mask.png
  35. BIN ...ontrol_images/qgis_server_accesscontrol/WMS_GetLegendGraphic_Hello/WMS_GetLegendGraphic_Hello.png
  36. BIN ...l_images/qgis_server_accesscontrol/WMS_GetLegendGraphic_Hello/WMS_GetLegendGraphic_Hello_mask.png
  37. BIN tests/testdata/qgis_server_accesscontrol/geo.gpkg
@@ -543,6 +543,7 @@ QSizeF QgsLegendRenderer::drawLayerTitle( QgsLayerTreeLayer *nodeLayer, QPainter
}
}
size.rheight() = y - point.y();
size.rheight() += mSettings.style( nodeLegendStyle( nodeLayer ) ).margin( QgsLegendStyle::Side::Bottom );

return size;
}
@@ -1109,12 +1109,13 @@ namespace QgsWms
settings.setBoxSpace( boxSpaceAsDouble() );
settings.setSymbolSize( QSizeF( symbolWidthAsDouble(), symbolHeightAsDouble() ) );

settings.rstyle( QgsLegendStyle::Subgroup ).setMargin( QgsLegendStyle::Top, layerSpaceAsDouble() );
settings.rstyle( QgsLegendStyle::Subgroup ).setFont( layerFont() );
settings.rstyle( QgsLegendStyle::Style::Subgroup ).setMargin( QgsLegendStyle::Side::Top, layerSpaceAsDouble() );
settings.rstyle( QgsLegendStyle::Style::Subgroup ).setMargin( QgsLegendStyle::Side::Bottom, layerTitleSpaceAsDouble() );
settings.rstyle( QgsLegendStyle::Style::Subgroup ).setFont( layerFont() );

settings.rstyle( QgsLegendStyle::SymbolLabel ).setFont( itemFont() );
settings.rstyle( QgsLegendStyle::Symbol ).setMargin( QgsLegendStyle::Top, symbolSpaceAsDouble() );
settings.rstyle( QgsLegendStyle::SymbolLabel ).setMargin( QgsLegendStyle::Left, iconLabelSpaceAsDouble() );
settings.rstyle( QgsLegendStyle::Style::SymbolLabel ).setFont( itemFont() );
settings.rstyle( QgsLegendStyle::Style::Symbol ).setMargin( QgsLegendStyle::Side::Top, symbolSpaceAsDouble() );
settings.rstyle( QgsLegendStyle::Style::SymbolLabel ).setMargin( QgsLegendStyle::Side::Left, iconLabelSpaceAsDouble() );

return settings;
}
@@ -185,6 +185,10 @@ def _img_diff(self, image, control_image, max_diff, max_size_diff=QSize()):
return control.compareImages(control_image, max_diff), control.report()

def _img_diff_error(self, response, headers, image, max_diff=100, max_size_diff=QSize()):

reference_path = unitTestDataPath('control_images') + '/qgis_server/' + image + '/' + image + '.png'
self.store_reference(reference_path, response)

self.assertEqual(
headers.get("Content-Type"), "image/png",
"Content type is wrong: %s\n%s" % (headers.get("Content-Type"), response))
@@ -217,6 +217,10 @@ def _img_diff(self, image, control_image, max_diff, max_size_diff=QSize()):
return control.compareImages(control_image), control.report()

def _img_diff_error(self, response, headers, image, max_diff=10, max_size_diff=QSize()):

reference_path = unitTestDataPath('control_images') + '/qgis_server_accesscontrol/' + image + '/' + image + '.png'
self.store_reference(reference_path, response)

self.assertEqual(
headers.get("Content-Type"), "image/png",
"Content type is wrong: %s" % headers.get("Content-Type"))
@@ -24,6 +24,9 @@

class TestQgsServerAccessControlWMSGetlegendgraphic(TestQgsServerAccessControl):

# Set to True to re-generate reference files for this class
#regenerate_reference = True

def test_wms_getlegendgraphic_hello(self):
query_string = "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
@@ -40,9 +40,11 @@


class TestQgsServerWMSGetLegendGraphic(QgsServerTestBase):

"""QGIS Server WMS Tests for GetLegendGraphic request"""

# Set to True to re-generate reference files for this class
#regenerate_reference = True

def test_getLegendGraphics(self):
"""Test that does not return an exception but an image"""
parms = {
@@ -103,7 +105,31 @@ def test_wms_GetLegendGraphic_LayerSpace(self):
}.items())])

r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_LayerSpace")
self._img_diff_error(r, h, "WMS_GetLegendGraphic_LayerSpace", max_size_diff=QSize(1, 1))

def test_wms_GetLegendGraphic_LayerTitleSpace(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello",
"FORMAT": "image/png",
# "HEIGHT": "500",
# "WIDTH": "500",
"LAYERTITLESPACE": "20.0",
"LAYERFONTBOLD": "TRUE",
"LAYERFONTSIZE": "30",
"ITEMFONTBOLD": "TRUE",
"ITEMFONTSIZE": "20",
"LAYERFONTFAMILY": self.fontFamily,
"ITEMFONTFAMILY": self.fontFamily,
"LAYERTITLE": "TRUE",
"CRS": "EPSG:3857"
}.items())])

r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_LayerTitleSpace")

def test_wms_GetLegendGraphic_ShowFeatureCount(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
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.
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.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file not shown.

0 comments on commit f075109

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