Skip to content
Permalink
Browse files

Merge pull request #9889 from elpaso/bugfix-21917-server-root-layer-o…

…rder-3_4

Respect custom layer order for groups in GetMap
  • Loading branch information
elpaso committed Apr 29, 2019
2 parents b5741c2 + aa714d3 commit 8131f8c26cb96220fa0f57afd8dc73749d3b5ba1
@@ -2496,9 +2496,33 @@ namespace QgsWms
if ( !groupName.isEmpty() )
{
mLayerGroups[groupName] = QList<QgsMapLayer *>();
for ( QgsLayerTreeLayer *layer : group->findLayers() )
const auto projectLayerTreeRoot { mProject->layerTreeRoot() };
const auto treeGroupLayers { group->findLayers() };
// Fast track if there is no custom layer order,
// otherwise reorder layers.
if ( ! projectLayerTreeRoot->hasCustomLayerOrder() )
{
mLayerGroups[groupName].append( layer->layer() );
for ( const auto &tl : treeGroupLayers )
{
mLayerGroups[groupName].push_back( tl->layer() );
}
}
else
{
const auto projectLayerOrder { projectLayerTreeRoot->layerOrder() };
// Flat list containing the layers from the tree nodes
QList<QgsMapLayer *> groupLayersList;
for ( const auto &tl : treeGroupLayers )
{
groupLayersList << tl->layer();
}
for ( const auto &l : projectLayerOrder )
{
if ( groupLayersList.contains( l ) )
{
mLayerGroups[groupName].push_back( l );
}
}
}
}

@@ -1427,6 +1427,50 @@ def test_wms_getmap_group_regression_20810(self):
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_GroupedLayersDown")

def test_wms_getmap_root_custom_layer_order_regression_21917(self):
"""When drawing root layer, custom layer order order should be respected."""

qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(os.path.join(self.testdata_path, 'bug_21917_root_layer_order.qgs')),
"SERVICE": "WMS",
"VERSION": "1.3.0",
"REQUEST": "GetMap",
"BBOX": "44.9014,8.20346,44.9015,8.20355",
"CRS": "EPSG:4326",
"WIDTH": "400",
"HEIGHT": "400",
"LAYERS": "group",
"STYLES": ",",
"FORMAT": "image/png",
"DPI": "200",
"MAP_RESOLUTION": "200",
"FORMAT_OPTIONS": "dpi:200"
}.items())])

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

# Check with root_layer
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(os.path.join(self.testdata_path, 'bug_21917_root_layer_order.qgs')),
"SERVICE": "WMS",
"VERSION": "1.3.0",
"REQUEST": "GetMap",
"BBOX": "44.9014,8.20346,44.9015,8.20355",
"CRS": "EPSG:4326",
"WIDTH": "400",
"HEIGHT": "400",
"LAYERS": "root_layer",
"STYLES": ",",
"FORMAT": "image/png",
"DPI": "200",
"MAP_RESOLUTION": "200",
"FORMAT_OPTIONS": "dpi:200"
}.items())])

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


if __name__ == '__main__':
unittest.main()
Binary file not shown.

0 comments on commit 8131f8c

Please sign in to comment.
You can’t perform that action at this time.