Skip to content

Commit 6722ad5

Browse files
committed
fallback possibility if HEIGHT is used on GetLegendGraphics for maps as well
1 parent e184772 commit 6722ad5

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

src/server/services/wms/qgswmsparameters.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -718,18 +718,17 @@ namespace QgsWms
718718

719719
int QgsWmsParameters::getHeightAsInt() const
720720
{
721-
if ( request().compare( QStringLiteral( "GetLegendGraphic" ), Qt::CaseInsensitive ) != 0 &&
722-
request().compare( QStringLiteral( "GetLegendGraphics" ), Qt::CaseInsensitive ) != 0 )
723-
return heightAsInt();
724-
return srcHeightAsInt();
721+
if ( QStringList( { QStringLiteral( "GetLegendGraphic" ), QStringLiteral( "GetLegendGraphics" ) } ).contains( request() ) && srcHeightAsInt() > 0 )
722+
return srcHeightAsInt();
723+
return heightAsInt();
725724
}
726725

727726
int QgsWmsParameters::getWidthAsInt() const
728727
{
729-
if ( request().compare( QStringLiteral( "GetLegendGraphic" ), Qt::CaseInsensitive ) != 0 &&
730-
request().compare( QStringLiteral( "GetLegendGraphics" ), Qt::CaseInsensitive ) != 0 )
731-
return widthAsInt();
732-
return srcWidthAsInt();
728+
729+
if ( QStringList( { QStringLiteral( "GetLegendGraphic" ), QStringLiteral( "GetLegendGraphics" ) } ).contains( request() ) && srcWidthAsInt() > 0 )
730+
return srcWidthAsInt();
731+
return widthAsInt();
733732
}
734733

735734
QString QgsWmsParameters::dpi() const

tests/src/python/test_qgsserver_wms_getlegendgraphic.py

+36
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,42 @@ def test_wms_GetLegendGraphic_BBox2(self):
495495
r, h = self._result(self._execute_request(qs))
496496
self._img_diff_error(r, h, "WMS_GetLegendGraphic_BBox2")
497497

498+
def test_wms_GetLegendGraphic_BBox_Fallback(self):
499+
qs = "?" + "&".join(["%s=%s" % i for i in list({
500+
"MAP": urllib.parse.quote(self.projectPath),
501+
"SERVICE": "WMS",
502+
"VERSION": "1.1.1",
503+
"REQUEST": "GetLegendGraphic",
504+
"LAYER": "Country,Hello,db_point",
505+
"LAYERTITLE": "FALSE",
506+
"FORMAT": "image/png",
507+
"HEIGHT": "500",
508+
"WIDTH": "500",
509+
"BBOX": "-151.7,-38.9,51.0,78.0",
510+
"CRS": "EPSG:4326"
511+
}.items())])
512+
513+
r, h = self._result(self._execute_request(qs))
514+
self._img_diff_error(r, h, "WMS_GetLegendGraphic_BBox")
515+
516+
def test_wms_GetLegendGraphic_BBox2_Fallback(self):
517+
qs = "?" + "&".join(["%s=%s" % i for i in list({
518+
"MAP": urllib.parse.quote(self.projectPath),
519+
"SERVICE": "WMS",
520+
"VERSION": "1.1.1",
521+
"REQUEST": "GetLegendGraphic",
522+
"LAYER": "Country,Hello,db_point",
523+
"LAYERTITLE": "FALSE",
524+
"FORMAT": "image/png",
525+
"HEIGHT": "500",
526+
"WIDTH": "500",
527+
"BBOX": "-76.08,-6.4,-19.38,38.04",
528+
"SRS": "EPSG:4326"
529+
}.items())])
530+
531+
r, h = self._result(self._execute_request(qs))
532+
self._img_diff_error(r, h, "WMS_GetLegendGraphic_BBox2")
533+
498534
def test_wms_GetLegendGraphic_EmptyLegend(self):
499535
qs = "?" + "&".join(["%s=%s" % i for i in list({
500536
"MAP": self.testdata_path + 'test_project_contextual_legend.qgs',

0 commit comments

Comments
 (0)