Navigation Menu

Skip to content

Commit

Permalink
fallback possibility if HEIGHT is used on GetLegendGraphics for maps …
Browse files Browse the repository at this point in the history
…as well
  • Loading branch information
signedav committed Mar 27, 2019
1 parent e184772 commit 6722ad5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/server/services/wms/qgswmsparameters.cpp
Expand Up @@ -718,18 +718,17 @@ namespace QgsWms

int QgsWmsParameters::getHeightAsInt() const
{
if ( request().compare( QStringLiteral( "GetLegendGraphic" ), Qt::CaseInsensitive ) != 0 &&
request().compare( QStringLiteral( "GetLegendGraphics" ), Qt::CaseInsensitive ) != 0 )
return heightAsInt();
return srcHeightAsInt();
if ( QStringList( { QStringLiteral( "GetLegendGraphic" ), QStringLiteral( "GetLegendGraphics" ) } ).contains( request() ) && srcHeightAsInt() > 0 )
return srcHeightAsInt();
return heightAsInt();
}

int QgsWmsParameters::getWidthAsInt() const
{
if ( request().compare( QStringLiteral( "GetLegendGraphic" ), Qt::CaseInsensitive ) != 0 &&
request().compare( QStringLiteral( "GetLegendGraphics" ), Qt::CaseInsensitive ) != 0 )
return widthAsInt();
return srcWidthAsInt();

if ( QStringList( { QStringLiteral( "GetLegendGraphic" ), QStringLiteral( "GetLegendGraphics" ) } ).contains( request() ) && srcWidthAsInt() > 0 )
return srcWidthAsInt();
return widthAsInt();
}

QString QgsWmsParameters::dpi() const
Expand Down
36 changes: 36 additions & 0 deletions tests/src/python/test_qgsserver_wms_getlegendgraphic.py
Expand Up @@ -495,6 +495,42 @@ def test_wms_GetLegendGraphic_BBox2(self):
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_BBox2")

def test_wms_GetLegendGraphic_BBox_Fallback(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,db_point",
"LAYERTITLE": "FALSE",
"FORMAT": "image/png",
"HEIGHT": "500",
"WIDTH": "500",
"BBOX": "-151.7,-38.9,51.0,78.0",
"CRS": "EPSG:4326"
}.items())])

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

def test_wms_GetLegendGraphic_BBox2_Fallback(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,db_point",
"LAYERTITLE": "FALSE",
"FORMAT": "image/png",
"HEIGHT": "500",
"WIDTH": "500",
"BBOX": "-76.08,-6.4,-19.38,38.04",
"SRS": "EPSG:4326"
}.items())])

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

def test_wms_GetLegendGraphic_EmptyLegend(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": self.testdata_path + 'test_project_contextual_legend.qgs',
Expand Down

0 comments on commit 6722ad5

Please sign in to comment.