Skip to content
Permalink
Browse files
Merge pull request #5084 from pblottiere/server_bugfix_ogc_mode
[server][bugfix] Fixes OGC test on getmap:each-format mode for 1bit/8bit/16bit
  • Loading branch information
pblottiere committed Sep 6, 2017
2 parents 2e20b6f + eb9e2ac commit 3b839ce
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 2 deletions.
@@ -94,7 +94,7 @@ namespace QgsWms
QRegularExpression::CaseInsensitiveOption );

QRegularExpressionMatch match = modeExpr.match( format );
QString mode = match.captured();
QString mode = match.captured( 1 );
if ( mode.compare( QLatin1String( "16bit" ), Qt::CaseInsensitive ) == 0 )
return PNG16;
if ( mode.compare( QLatin1String( "8bit" ), Qt::CaseInsensitive ) == 0 )
@@ -163,7 +163,7 @@ def _img_diff(self, image, control_image, max_diff, max_size_diff=QSize()):
control.setRenderedImage(temp_image)
if max_size_diff.isValid():
control.setSizeTolerance(max_size_diff.width(), max_size_diff.height())
return control.compareImages(control_image), control.report()
return control.compareImages(control_image, max_diff), control.report()

def _img_diff_error(self, response, headers, image, max_diff=10, max_size_diff=QSize()):
self.assertEqual(
@@ -176,6 +176,61 @@ def test_project_wms_inspire(self):
for request in ('GetCapabilities',):
self.wms_inspire_request_compare(request)

def test_wms_getmap_basic_mode(self):
# 1 bits
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; mode=1bit",
"BBOX": "-16817707,-4710778,5696513,14587125",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:3857"
}.items())])

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

# 8 bits
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; mode=8bit",
"BBOX": "-16817707,-4710778,5696513,14587125",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:3857"
}.items())])

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

# 16 bits
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; mode=16bit",
"BBOX": "-16817707,-4710778,5696513,14587125",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:3857"
}.items())])

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

def test_wms_getmap_basic(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3b839ce

Please sign in to comment.