Skip to content

Commit

Permalink
Using Lizmap\Project\Qgis\ProjectInfo in QgisProject::readLayersOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Oct 1, 2024
1 parent 2737bf1 commit f7eb998
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions lizmap/modules/lizmap/lib/Project/QgisProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -1321,15 +1321,29 @@ public function readAttributeLayers($attributeLayers)
}

/**
* @param \SimpleXMLElement $xml
* @param mixed $layers
*
* @return int[]
*/
public function readLayersOrder($xml, $layers)
public function readLayersOrder($layers)
{
$layersOrder = array();
if ($this->qgisProjectVersion >= 30000) { // For QGIS >=3.0, custom-order is in layer-tree-group
if ($this->path) {
$project = Qgis\ProjectInfo::fromQgisPath($this->path);
$customOrder = $project->layerTreeRoot->customOrder;
if (!$customOrder->enabled) {
return $layersOrder;
}
$lo = 0;
foreach ($customOrder->items as $layerI) {
// Get layer name from config instead of XML for possible embedded layers
$name = $this->getLayerNameByIdFromConfig($layerI, $layers);
if ($name) {
$layersOrder[$name] = $lo;
}
++$lo;
}
} else if ($this->qgisProjectVersion >= 30000) { // For QGIS >=3.0, custom-order is in layer-tree-group
$customOrder = $this->getXml()->xpath('layer-tree-group/custom-order');
if (count($customOrder) == 0) {
return $layersOrder;
Expand Down

0 comments on commit f7eb998

Please sign in to comment.