mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Merge pull request #6285 from tudorbarascu/dpi
fix server issue for double devicePixelRatio leading to DPI requests with decimals
This commit is contained in:
commit
a9d61ff508
@ -685,9 +685,9 @@ namespace QgsWms
|
||||
return value( ParameterName::DPI ).toString();
|
||||
}
|
||||
|
||||
int QgsWmsParameters::dpiAsInt() const
|
||||
double QgsWmsParameters::dpiAsDouble() const
|
||||
{
|
||||
return toInt( ParameterName::DPI );
|
||||
return toDouble( ParameterName::DPI );
|
||||
}
|
||||
|
||||
QString QgsWmsParameters::version() const
|
||||
|
@ -892,7 +892,7 @@ namespace QgsWms
|
||||
* \returns dpi parameter
|
||||
* \throws QgsBadRequestException
|
||||
*/
|
||||
int dpiAsInt() const;
|
||||
double dpiAsDouble() const;
|
||||
|
||||
/**
|
||||
* Returns TEMPLATE parameter or an empty string if not defined.
|
||||
|
@ -1046,7 +1046,7 @@ namespace QgsWms
|
||||
double OGC_PX_M = 0.00028; // OGC reference pixel size in meter, also used by qgis
|
||||
int dpm = 1 / OGC_PX_M;
|
||||
if ( !mWmsParameters.dpi().isEmpty() )
|
||||
dpm = mWmsParameters.dpiAsInt() / 0.0254;
|
||||
dpm = mWmsParameters.dpiAsDouble() / 0.0254;
|
||||
|
||||
image->setDotsPerMeterX( dpm );
|
||||
image->setDotsPerMeterY( dpm );
|
||||
|
@ -184,6 +184,25 @@ class TestQgsServerWMSGetMap(QgsServerTestBase):
|
||||
r, h = self._result(self._execute_request(qs))
|
||||
self._img_diff_error(r, h, "WMS_GetMap_Basic4")
|
||||
|
||||
def test_wms_getmap_dpi(self):
|
||||
qs = "?" + "&".join(["%s=%s" % i for i in list({
|
||||
"MAP": urllib.parse.quote(self.projectPath),
|
||||
"SERVICE": "WMS",
|
||||
"VERSION": "1.1.1",
|
||||
"REQUEST": "GetMap",
|
||||
"LAYERS": "Country",
|
||||
"STYLES": "",
|
||||
"FORMAT": "image/png",
|
||||
"BBOX": "-16817707,-4710778,5696513,14587125",
|
||||
"HEIGHT": "500",
|
||||
"WIDTH": "500",
|
||||
"CRS": "EPSG:3857",
|
||||
"DPI": "112.5"
|
||||
}.items())])
|
||||
|
||||
r, h = self._result(self._execute_request(qs))
|
||||
self._img_diff_error(r, h, "WMS_GetMap_Basic5")
|
||||
|
||||
def test_wms_getmap_invalid_parameters(self):
|
||||
# height should be an int
|
||||
qs = "?" + "&".join(["%s=%s" % i for i in list({
|
||||
|
BIN
tests/testdata/control_images/qgis_server/WMS_GetMap_Basic5/WMS_GetMap_Basic5.png
vendored
Normal file
BIN
tests/testdata/control_images/qgis_server/WMS_GetMap_Basic5/WMS_GetMap_Basic5.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
Loading…
x
Reference in New Issue
Block a user