Skip to content

Commit

Permalink
Merge pull request #6251 from elpaso/bugfix-17975-server-layer-groups…
Browse files Browse the repository at this point in the history
…-order

[bugfix][server] WMS respect order of grouped layers
  • Loading branch information
elpaso committed Feb 5, 2018
2 parents b6c2de4 + e3b054b commit 7bf0a7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -2612,7 +2612,7 @@ namespace QgsWms
{
layer->readSld( namedElem, err );
layer->setCustomProperty( "readSLD", true );
layers.append( layer );
layers.insert( 0, layer );
}
}
}
Expand Down Expand Up @@ -2676,7 +2676,7 @@ namespace QgsWms
throw QgsMapServiceException( QStringLiteral( "StyleNotDefined" ), QStringLiteral( "Style \"%1\" does not exist for layer \"%2\"" ).arg( style, layerNickname( *layer ) ) );
}
}
layers.append( layer );
layers.insert( 0, layer );
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion tests/src/python/test_qgsserver_wms_getmap.py
Expand Up @@ -890,12 +890,15 @@ def test_wms_getmap_sld(self):
self._img_diff_error(r, h, "WMS_GetMap_SLDRestored")

def test_wms_getmap_group(self):
"""A WMS shall render the requested layers by drawing the leftmost in the list
bottommost, the next one over that, and so on."""

qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectGroupsPath),
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"LAYERS": "Country,Country_Labels,Country_Diagrams",
"LAYERS": "Country_Diagrams,Country_Labels,Country",
"STYLES": "",
"FORMAT": "image/png",
"BBOX": "-16817707,-4710778,5696513,14587125",
Expand All @@ -921,6 +924,16 @@ def test_wms_getmap_group(self):
}.items())])

r_group, _ = self._result(self._execute_request(qs))

""" Debug check:
f = open('grouped.png', 'wb+')
f.write(r_group)
f.close()
f = open('individual.png', 'wb+')
f.write(r_individual)
f.close()
#"""

self.assertEqual(r_individual, r_group, 'Individual layers query and group layers query results should be identical')

qs = "?" + "&".join(["%s=%s" % i for i in list({
Expand Down

0 comments on commit 7bf0a7f

Please sign in to comment.