Exemple #1
0
 public function createGroup($grpName, $layerList)
 {
     $group = new GROUP($grpName);
     $i = 1;
     // Loop through LAYERS of current group
     foreach ($layerList as $layIdx) {
         // Get layer info from map file
         $mapLay = $this->map->getLayer($layIdx);
         $mapLayName = $mapLay->name;
         $mapLayType = $mapLay->type;
         $mapLayConnType = $mapLay->connectiontype;
         //error_log("$mapLayName - $mapLayConnType");
         // Write layer properties to glayer object
         $glayer = new GLAYER($mapLayName);
         $glayer->setLayerIdx($layIdx);
         $glayer->setLayerType($mapLayType);
         // Add result field list
         if ($mapLayType <= 4 && $mapLayConnType != MS_WMS) {
             // result fields only for queryable layers point (0), line (1), polygon (2), annotation (4)
             $selFields0 = $this->_initResultFields($this->map, $mapLay, $mapLayType);
             // Trim spaces
             if (is_array($selFields0)) {
                 if (count($selFields0) > 0) {
                     //pm_logDebug(3, $selFields0, "P.MAPPER-DEBUG: initgroups.php/createGroup()->selFields0");
                     $selFields = array();
                     foreach ($selFields0 as $sf0) {
                         // If field name starts with '&' then translate
                         $sf = substr(trim($sf0), 0, 1) == '&' ? _p(trim($sf0)) : trim($sf0);
                         $selFields[] = $sf;
                     }
                     $glayer->setResFields($selFields);
                 }
             }
         }
         // add to categories array if defined in map file
         if ($category = $this->getLayerMetaTag($mapLay, "CATEGORY")) {
             $this->_initCategories($mapLayName, $category);
         }
         // Add hyperlink fields
         if ($this->_getHyperFieldList($mapLay)) {
             $glayer->setHyperFields($this->_getHyperFieldList($mapLay));
         }
         // Add JOIN properties if defined
         if ($this->_getJoinProperties($mapLay)) {
             $glayer->setTableJoin($this->_getJoinProperties($mapLay));
         }
         // Add classes
         $numclasses = $mapLay->numclasses;
         $classes = array();
         for ($cl = 0; $cl < $numclasses; $cl++) {
             $class = $mapLay->getClass($cl);
             $className = $this->mapStringEncode($class->name);
             if (strlen($className) > 0) {
                 $classname = _p(trim($className));
                 $classes[] = $classname;
                 //str_replace("'", "\\'", $classname);
             }
         }
         $glayer->setClasses($classes);
         // Check/Set labelitems if defined
         if ($mapLay->labelitem) {
             $labelItem = $mapLay->labelitem[0] == "@" ? _p(substr($mapLay->labelitem, 1)) : $mapLay->labelitem;
             $glayer->setLabelItem($labelItem);
         }
         // Check/Set layer transparency (opacity)
         if (floatval($_SESSION['MS_VERSION']) >= 5) {
             $glayer->setOpacity($mapLay->opacity);
         } else {
             $glayer->setOpacity($mapLay->transparency);
         }
         // Check if layer is XY layer
         if ($XYLayerPropStr = $this->getLayerMetaTag($mapLay, "XYLAYER_PROPERTIES")) {
             $glayer->setXYLayerAttribute();
             $XYLayerPropList = $this->_getXYLayerPropList($XYLayerPropStr);
             $glayer->setXYLayerProperties($XYLayerPropList);
             pm_logDebug(3, $XYLayerPropList, "P.MAPPER-DEBUG: initgroups.php/_createGroups() - XYLayerProperties for layer {$mapLayName}");
             // Set in sessionid that XYLayer exists
             $this->existsXYLayer = 1;
         }
         //Check for skipLegend
         // 1: only for TOC_TREE, 2: always skip legend
         $skipLegend = $this->getLayerMetaTag($mapLay, "SKIP_LEGEND");
         $glayer->setSkipLegend($skipLegend);
         // Layer Encoding
         $glayer->setLayerEncoding($this->getLayerMetaTag($mapLay, "LAYER_ENCODING"));
         // DB properties
         if ($mapLayConnType == 6) {
             $glayer->setLayerDbProperties($this->pgLayerParseData($mapLay));
         }
         if ($mapLayConnType == 8) {
             $glayer->setLayerDbProperties($this->oraGetDbProperties($mapLay));
         }
         // now add layer to group
         $group->addLayer($glayer);
         // set group description and result headers, process only for 1st layer of group
         if ($i == 1) {
             // Set group description
             $description = $this->_initDescription($mapLay);
             $group->setDescription($description);
             // Set result group headers
             if ($mapLayType <= 4) {
                 $selHeadersList = $this->_initResultHeaders($this->map, $mapLay, $mapLayType, $this->gLanguage);
                 $group->setResHeaders($selHeadersList[0]);
                 $group->setResStdHeaders($selHeadersList[1]);
             }
             $i = 0;
         }
     }
     return $group;
 }