[fusion-commits] r2284 - trunk/layers/MapServer/php

svn_fusion at osgeo.org svn_fusion at osgeo.org
Mon Nov 22 13:58:03 EST 2010


Author: madair
Date: 2010-11-22 10:58:02 -0800 (Mon, 22 Nov 2010)
New Revision: 2284

Modified:
   trunk/layers/MapServer/php/LoadMap.php
Log:
re #79: allow for one level of nested grouping by using a "parentGroup" metadata element in the mapfile to list the parent group name

Modified: trunk/layers/MapServer/php/LoadMap.php
===================================================================
--- trunk/layers/MapServer/php/LoadMap.php	2010-11-19 19:59:39 UTC (rev 2283)
+++ trunk/layers/MapServer/php/LoadMap.php	2010-11-22 18:58:02 UTC (rev 2284)
@@ -199,6 +199,7 @@
     $mapObj->mapTitle = $title == "" ? $mapObj->mapName : $title;
     //layers
     $mapObj->layers = array();
+    $mapObj->groups = array();
     for ($i=0;$i<$oMap->numlayers;$i++)
     {
         $layer=$oMap->getLayer($i);
@@ -404,8 +405,23 @@
             $layerObj->maxScale = max($layerObj->maxScale, $aScaleRanges[$j]->maxScale);
         }
         array_push($mapObj->layers, $layerObj);
+        
+        //allow for nested groups using a "parentGroup" piece of metadata
+        $parent = $layer->getMetaData('parentGroup');
+        if (strlen($parent)>0) {
+          $alreadyListed = false;
+          foreach($mapObj->groups as $pGroup){
+              if ($pGroup->groupName == $parent) {
+                $alreadyListed = true;
+                break;
+              }
+          }
+          if (!$alreadyListed) {
+            array_push($mapObj->groups, getParentGroupObject($layer));
+          }
+        }
+
     }
-    $mapObj->groups = array();
     $aGroups = $oMap->getAllGroupNames();
     if (is_array($aGroups)) {
       foreach($aGroups as $groupName) {
@@ -415,6 +431,7 @@
           }
       }
     }
+    
     echo var2json($mapObj);
 }
 
@@ -429,7 +446,31 @@
     $b = $layer->getMetaData('groupExpandInLegend');
     $group->expandInLegend = ($b == 'false') ? false : true;
     $group->layerGroupType = '';
-    /* parent is always not set for mapserver since we can't have nested groups */
+    /* parent group for nested groups */
+    $parent = $layer->getMetaData('parentGroup');
+    $group->parentUniqueId = $parent;
+    $group->parent = $parent;
+    $b = $layer->getMetaData('groupVisible');
+    $group->visible = ($b == 'false') ? false : true;
+    $group->actuallyVisible = $layer->isVisible();
+    $group->groupParent = $layer->getMetaData('groupParent');
+
+    return $group;
+}
+
+function getParentGroupObject($layer) {
+    $parentGroup = $layer->getMetaData('parentGroup');
+    $group = NULL;
+    $group->groupName = $parentGroup;
+    $ll = $layer->getMetaData('parentGroupLegendLabel');
+    $group->legendLabel = $ll != '' ? $ll : $group->groupName;
+    $group->uniqueId = $group->groupName;
+    $b = $layer->getMetaData('groupDisplayInLegend');
+    $group->displayInLegend = ($b == 'false') ? false : true;
+    $b = $layer->getMetaData('groupExpandInLegend');
+    $group->expandInLegend = ($b == 'false') ? false : true;
+    $group->layerGroupType = '';
+    /* maybe do some parsing of the metadata to get parents of paretns? */
     $group->parentUniqueId = '';
     $group->parent = '';
     $b = $layer->getMetaData('groupVisible');



More information about the fusion-commits mailing list