Esempio n. 1
0
File: toc.php Progetto: sukma279/GIS
 /**
  * Create HTML output for categories
  * @return string
  */
 public function writeCategories()
 {
     $layerView = new LayerView($this->map, false);
     $categoryList = $layerView->getCategoryList();
     $html = "<ul>";
     foreach ($categoryList as $cat) {
         $name = $cat['name'];
         //$description = addslashes($cat['description']);
         $description = $cat['description'];
         $groups = $cat['groups'];
         if (count($groups) < 1) {
             continue;
         }
         $html .= "<li id=\"licat_{$name}\" class=\"toccat\">";
         if ($this->catWithCheckbox) {
             $html .= "<input type=\"checkbox\" name=\"catscbx\" value=\"{$name}\" id=\"cinput_{$name}\" \" />";
         }
         $html .= "<span class=\"vis cat-label\" id=\"spxg_{$name}\">{$description}</span>";
         // Add groups
         if (count($groups) > 0) {
             $html .= $this->writeGroups($groups);
         }
         $html .= "</li>";
     }
     $html .= "</ul>";
     return $html;
 }
Esempio n. 2
0
 /**
  * Create HTML output for groups
  */
 public function writeGroups($groupList = false, $mapExt = null)
 {
     $layerView = new LayerView($this->map, true, true);
     if ($mapExt) {
         $layerView->setMapExt($mapExt);
     }
     //$groupList = $layerView->getGroupList();
     $categoryList = $layerView->getCategoryList();
     //pm_logDebug(3, $categoryList, "writeGroups()");
     $html = "<ul>";
     foreach ($categoryList as $cat) {
         $groupList = $cat['groups'];
         if (count($groupList) > 0) {
             foreach ($groupList as $grp) {
                 $grpName = $grp['name'];
                 $grpDescr = $grp['description'];
                 $classList = $grp['classList'];
                 $numcls = count($classList);
                 if ($numcls > 0) {
                     $html .= "<li class=\"tocgrp\">";
                     $html .= "<span class=\"pm-leg-grp-title\">{$grpDescr}</span>";
                     // Add classes
                     $html .= $this->writeClasses($grpName, $classList);
                     $html .= "</li>";
                 }
             }
         }
     }
     $html .= "</ul>";
     //error_log($html);
     return $html;
 }
Esempio n. 3
0
 function printLegendPDF($map, $scale)
 {
     $defGroups = $_SESSION["defGroups"];
     $icoW = $_SESSION["icoW"] * $this->redFactor;
     // Width in pixels
     $icoH = $_SESSION["icoH"] * $this->redFactor;
     // Height in pixels
     $imgExt = $_SESSION["imgFormatExt"];
     $layerView = new LayerView($map, true, true, $scale);
     $categoryList = $layerView->getCategoryList();
     //pm_logDebug(3, $categoryList, "writeGroups()");
     $yCatSpB = round($this->defaultFontSize * 0.6);
     $yCatGrp = round($this->defaultFontSize * 2.3);
     $yGrpGrp = round($this->defaultFontSize * 2.1);
     $yGrpCls = round($this->defaultFontSize * 1.6);
     $yClsCls = round($this->defaultFontSize * 1.8);
     $yClsGrp = round($this->defaultFontSize * 2.2);
     $yClsAdd = round($this->defaultFontSize * 1.0);
     $yMCellH = round($this->defaultFontSize * 0.7);
     $xToLeft = round($this->defaultFontSize * 0.3);
     $xIcoTxt = round($this->defaultFontSize * 0.6);
     $yPageBreakThresh = 42;
     //round(($this->defaultFontSize * 4) + 4);
     $this->resetDefaultFont();
     // Due to possibility of having legend on the right,
     // few parameters could now be different on the 1st page, and on the following ones
     // Moreover, most of them are now class members
     $this->xColumnSize = ($this->xmaxM - $this->xminM + 2 * $this->margin) / $this->legendNumColumns + 5;
     //        $this->mcellWNewPage = (($this->xmaxM - $this->xminM) / 2) - $icoW - 38;
     $this->mcellWNewPage = ($this->xmaxM - $this->xminM) / $this->legendNumColumns - $icoW - 38;
     $this->x0 = $this->xLegStart + 10;
     $this->x0NewPage = $this->xminM + 10;
     $this->xLegend = $this->x0;
     $this->y0 = $this->yLegStart + 10;
     $this->y0NewPage = $this->yminM + 35 + 10;
     $this->yLegend = $this->y0;
     if ($this->legendPosition == "R") {
         $this->mcellW = $this->xmaxM - $this->xLegStart - $icoW - 38;
     } else {
         $this->mcellW = $this->mcellWNewPage;
     }
     foreach ($categoryList as $cat) {
         $catDescr = $cat['description'];
         $groupList = $cat['groups'];
         // check if category has one or more group with one or more class
         $catWithClass = false;
         if (count($groupList) > 0) {
             foreach ($groupList as $grp) {
                 $classList = $grp['classList'];
                 if (count($classList)) {
                     $catWithClass = true;
                     break;
                 }
             }
         }
         if ($catWithClass) {
             if ($this->pdfSettings['printCategory']) {
                 $this->yLegend += $yCatSpB;
                 // grouping things to do when adding page for legend:
                 $mcellH = $this->defaultFontSize + 2;
                 $mcellWcat = $this->mcellW + 35;
                 $this->SetFont($this->defaultFontType, "BU", $mcellH);
                 $height = 1;
                 if ($this->GetStringWidth($catDescr) >= $mcellWcat) {
                     // test if string is wider than cell box
                     $height = ceil($this->GetStringWidth($catDescr) / $mcellWcat);
                 }
                 $this->legendAddPageIfNeeded($yCatGrp * $height);
                 $this->SetXY($this->xLegend - $xToLeft, $this->yLegend);
                 if ($this->GetStringWidth($catDescr) >= $mcellWcat) {
                     // test if string is wider than cell box
                     $this->MultiCell($mcellWcat, $mcellH, $catDescr, 0, "L", 0);
                 } else {
                     $this->Cell(0, 0, $catDescr);
                 }
                 $this->yLegend += $yCatGrp * $height;
             }
             foreach ($groupList as $grp) {
                 $grpName = $grp['name'];
                 $grpDescr = $grp['description'];
                 $classList = $grp['classList'];
                 $this->numcls = count($classList);
                 // Only 1 class for all Layers -> 1 Symbol for Group
                 if ($this->numcls == 1) {
                     $cls = $classList[0];
                     $clsName = $cls['name'];
                     $iconUrl = $cls['iconUrl'];
                     // grouping things to do when adding page for legend:
                     $this->legendAddPageIfNeeded($yGrpGrp);
                     // Output PDF
                     $this->Image($iconUrl, $this->xLegend, $this->yLegend, $icoW, $icoH);
                     // outline rectangle for icons
                     $this->Rect($this->xLegend - 1, $this->yLegend - 1, $icoW + 1, $icoH + 1, "D");
                     $this->SetXY($this->xLegend + $icoW + $xIcoTxt, $this->yLegend);
                     $this->SetFont($this->defaultFontType, "B", $this->defaultFontSize);
                     // line height and interline depend on $mcellH
                     $mcellH = $this->defaultFontSize;
                     $mcellWgrp = $this->mcellW + $icoW;
                     if ($this->GetStringWidth($grpDescr) >= $mcellWgrp) {
                         // test if string is wider than cell box
                         $this->yadd = ceil($this->GetStringWidth($grpDescr) / $mcellWgrp) + 0.5;
                         $this->yLegend += $yMCellH * $this->yadd;
                         $this->MultiCell($mcellWgrp, $mcellH, $grpDescr, 0, "L", 0);
                     } else {
                         $this->Cell(0, 0, $grpDescr);
                     }
                     $this->yLegend += $yGrpGrp;
                     // y-difference between GROUPS
                     // More than 2 classes for Group  -> symbol for *every* class
                 } elseif ($this->numcls > 1) {
                     // grouping things to do when adding page for legend:
                     $this->legendAddPageIfNeeded($yGrpCls);
                     $this->SetXY($this->xLegend - $xToLeft, $this->yLegend);
                     $this->SetFont($this->defaultFontType, "B", $this->defaultFontSize);
                     // too long lines
                     $mcellWgrp = $this->mcellW + $icoW;
                     if ($this->GetStringWidth($grpDescr) >= $mcellWgrp) {
                         // test if string is wider than cell box
                         $this->yadd = ceil($this->GetStringWidth($grpDescr) / $mcellWgrp) + 0.5;
                         $this->yLegend += $yMCellH * $this->yadd;
                         $this->MultiCell($mcellWgrp, $mcellH, $grpDescr, 0, "L", 0);
                     } else {
                         $this->Cell(0, 0, $grpDescr);
                     }
                     $this->yLegend += $yGrpCls;
                     // y-difference between GROUP NAME and first class element
                     $allc = 0;
                     $this->clscnt = 0;
                     #if ($clscnt < $numcls) {
                     // too long lines
                     $this->yadd = 0;
                     foreach ($classList as $cls) {
                         $clsName = $cls['name'];
                         $iconUrl = $cls['iconUrl'];
                         $clno = 0;
                         // What to do if CLASS string is too large for cell box
                         if ($this->GetStringWidth($clsName) >= $this->mcellW) {
                             // test if string is wider than cell box
                             // line height and interline depend on $mcellH
                             $ydiff = -1;
                             // Modifyed by Walter Lorenzetti
                             // Modified by Thomas RAFFIN (SIRAP)
                             // rows number fo multicell is bigger than 2
                             // row number cell
                             $this->yadd = max($this->yadd, ceil($this->GetStringWidth($clsName) / $this->mcellW));
                         } else {
                             // line height and interline depend on $mcellH
                             $ydiff = 0;
                         }
                         // grouping things to do when adding page for legend:
                         $this->legendAddPageIfNeeded($yClsCls + $yMCellH * $this->yadd);
                         // Output PDF
                         $this->Image($iconUrl, $this->xLegend, $this->yLegend, $icoW, $icoH);
                         // outline rectangle for icons
                         $this->Rect($this->xLegend - 1, $this->yLegend - 1, $icoW + 1, $icoH + 1, "D");
                         $this->SetFont($this->defaultFontType, "", $this->defaultFontSize);
                         $this->SetXY($this->xLegend + $icoW + $xIcoTxt, $this->yLegend + $ydiff);
                         $this->MultiCell($this->mcellW, $mcellH, $clsName, 0, "L", 0);
                         // after printing RIGHT column or
                         // new group when number of printed classes equals total class number
                         // last class of a group or only one column in the output PDF (legend on the right for instance)
                         if ($this->legendPosition == 'BC' || ($this->clscnt % $this->legendNumColumns == $this->legendNumColumns - 1 || $this->clscnt == $this->numcls - 1 || $this->legendCurrentColumn == $this->legendCurrentPageNumColumns)) {
                             if ($this->clscnt != $this->numcls - 1) {
                                 $this->yLegend += $yClsCls;
                             }
                             if ($this->legendPosition != 'BC') {
                                 $this->xLegend = $this->x0;
                             }
                             if ($this->yadd) {
                                 $this->yLegend += $yMCellH * $this->yadd;
                                 // yadd : offset due to multiple lines for 1 description
                             }
                             $this->yadd = 0;
                             // after printing LEFT column
                         } else {
                             $this->xLegend += $this->xColumnSize;
                             // Continue in same group, add only new class item
                         }
                         // Begin new group when number of printed classes equals total class number
                         if ($this->clscnt == $this->numcls - 1) {
                             $this->yLegend += $yClsGrp;
                         }
                         $allc++;
                         $this->clscnt++;
                         // if Y too big add new PDF page and reset Y to beginning of document
                     }
                 }
             }
         }
     }
 }
Esempio n. 4
0
/**
 * Return groups available in array
 */
function getAvailableGroups($map, $onlyChecked, $onlyNonRasters, $onlyVisibleAtScale, $onlyQueryable = true, $onlyInCategories = false)
{
    // only checked groups :
    if ($onlyChecked) {
        $groupsStep1 = $_SESSION["groups"];
    } else {
        $groupsStep1 = $_SESSION["allGroups"];
    }
    $groupsStep2 = array();
    $scale = $_SESSION["geo_scale"];
    $grouplist = $_SESSION["grouplist"];
    foreach ($grouplist as $grp) {
        if (in_array($grp->getGroupName(), $groupsStep1, TRUE)) {
            $glayerList = $grp->getLayers();
            foreach ($glayerList as $glayer) {
                $mapLayer = $map->getLayer($glayer->getLayerIdx());
                $groupOk = true;
                // no raster layers / groups :
                if ($groupOk && $onlyNonRasters) {
                    if ($mapLayer->type >= 3) {
                        $groupOk = false;
                    }
                }
                // only visible layers / groups depending on scale :
                if ($groupOk && $onlyVisibleAtScale) {
                    if (PMCommon::checkScale($map, $mapLayer, $scale) != 1) {
                        $groupOk = false;
                    }
                }
                if ($groupOk && $onlyQueryable) {
                    $hasTemplate = 0;
                    if ($mapLayer->template) {
                        $hasTemplate = 1;
                    }
                    if (!$hasTemplate) {
                        $numclasses = $mapLayer->numclasses;
                        for ($cl = 0; $cl < $numclasses; $cl++) {
                            $class = $mapLayer->getClass($cl);
                            $classTemplate = $class->template;
                            if ($class->template) {
                                $hasTemplate = 1;
                                break;
                            }
                        }
                    }
                    $groupOk = $hasTemplate;
                }
                if ($groupOk) {
                    $groupsStep2[] = $grp;
                    break;
                }
            }
        }
    }
    // only layers in categories
    $groupsStep3 = array();
    if ($onlyInCategories) {
        // get Categories
        require_once $_SESSION['PM_INCPHP'] . "/layerview.php";
        $layerView = new LayerView($map, false, false);
        $categoryList = $layerView->getCategoryList();
        if (count($categoryList) > 0) {
            foreach ($categoryList as $cat) {
                $catGrps = $cat['groups'];
                $categoriesGroups = array();
                foreach ($catGrps as $catGrp) {
                    if ($catGrp) {
                        $catGrpName = $catGrp['name'];
                        foreach ($groupsStep2 as $grp) {
                            $grpName = $grp->getGroupName();
                            if ($catGrpName === $grpName) {
                                $groupsStep3[] = $grp;
                            }
                        }
                    }
                }
            }
        }
    } else {
        $groupsStep3 = $groupsStep2;
    }
    return $groupsStep3;
}