コード例 #1
0
ファイル: legend.php プロジェクト: sukma279/GIS
 /**
  * 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;
 }
コード例 #2
0
ファイル: x_layerview.php プロジェクト: sukma279/GIS
 * p.mapper is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version. See the COPYING file.
 *
 * p.mapper is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with p.mapper; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 ******************************************************************************/
require_once "../group.php";
require_once "../pmsession.php";
require_once "../common.php";
require_once "../globals.php";
require_once "../layerview.php";
$categories = $_SESSION['useCategories'] ? $_SESSION['categories'] : false;
$layerView = new LayerView($map, $categories, false);
$groupList = json_encode($layerView->getGroupList());
pm_logDebug(3, $groupList, "Group list: ");
//$categoryList = $layerView->getCategoryList();
//pm_logDebug(3, $categoryList, "category List: ");
//$groupList = $layerView->getGroupNameList();
//pm_logDebug(3, $groupList, "Group list: ");
header("Content-Type: text/plain; charset={$defCharset}");
// return JS object literals "{}" for XMLHTTP request
echo "{\"groupList\":{$groupList}}";
コード例 #3
0
ファイル: pdfprint.php プロジェクト: sukma279/GIS
 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
                     }
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: print.php プロジェクト: sukma279/GIS
 /**
  * CREATES HTML LEGEND FOR PRINT OUTPUT
  */
 function writePrintLegendHTML()
 {
     $layerView = new LayerView($this->map, true, true, $this->scale);
     $grouplist = $layerView->getGroupList();
     $icoW = $_SESSION["icoW"];
     // Width in pixels
     $icoH = $_SESSION["icoH"];
     // Height in pixels
     $html = "<table class=\"print_legendtable\"> \n";
     foreach ($grouplist as $grp) {
         // Only 1 class for Layer -> 1 Symbol for Group
         $classList = $grp['classList'];
         $numcls = count($classList);
         if ($numcls == 1) {
             $iconUrl = $classList[0]['iconUrl'];
             $html .= "<tr>";
             $html .= "<th><img src=\"{$iconUrl}\" width=\"{$icoW}\" height=\"{$icoH}\" alt=\"ico\" /></th>";
             $html .= "<th style=\"width:100%\" colspan=\"3\">" . $grp['description'] . "</th>";
             $html .= "</tr> \n";
             // More than 2 classes for Group  -> symbol for *every* class
         } elseif ($numcls > 1) {
             $html .= "\n  <tr><th colspan=\"4\">" . $grp['description'] . "</th></tr> \n";
             $clscnt = 0;
             foreach ($classList as $cls) {
                 $clsName = $cls['name'];
                 $iconUrl = $cls['iconUrl'];
                 $html .= $clscnt % 2 ? "" : "<tr>";
                 $html .= "<td style=\"width:{$icoW}\"><img src=\"{$iconUrl}\" width=\"{$icoW}\" height=\"{$icoH}\" alt=\"ico\" /> </td>";
                 $html .= "<td>{$clsName}</td> ";
                 if ($clscnt % 2) {
                     // after printing RIGHT column
                     $html .= "  </tr> \n";
                 } else {
                     // after printing LEFT column
                     if ($clscnt == $numcls - 1) {
                         // Begin new group when number of printed classes equals total class number
                         $html .= "<td></td></tr> \n";
                     } else {
                         // Continue in same group, add only new class item
                     }
                 }
                 $clscnt++;
             }
         }
     }
     $html .= "</table> \n";
     return $html;
 }
コード例 #5
0
ファイル: x_toc_update.php プロジェクト: sukma279/GIS
require_once "../globals.php";
require_once "../layerview.php";
header("Content-Type: text/plain; charset={$defCharset}");
$scale = $_SESSION["geo_scale"];
$grouplist = $_SESSION["grouplist"];
$defGroups = $_SESSION["defGroups"];
$allGroups = $_SESSION["allGroups"];
$imgFormat = $_SESSION["imgFormat"];
$scaleLayers = $_SESSION["scaleLayers"];
$legendStyle = $_SESSION["legendStyle"];
//$layerAutoRefresh = $_SESSION['layerAutoRefresh'];
// GET LAYERS FOR DRAWING AND IDENTIFY
if (isset($_SESSION["groups"]) && count($_SESSION["groups"]) > 0) {
    $groups = $_SESSION["groups"];
} else {
    $groups = $defGroups;
}
$layerList = array();
$layerView = new LayerView($map, true, false);
$visibleGroupList = $layerView->getGroupNameList();
foreach ($allGroups as $grpName) {
    if (in_array($grpName, $visibleGroupList)) {
        $layerList[] = "\"{$grpName}\":\"vis\"";
    } else {
        $layerList[] = "\"{$grpName}\":\"unvis\"";
    }
}
// JS layer object literal
$layers = '{' . implode(',', $layerList) . '}';
// return JS object literals "{}" for XMLHTTP request
echo "{\"layers\":{$layers}, \"legendStyle\":\"{$legendStyle}\"}";
コード例 #6
0
ファイル: toc.php プロジェクト: sukma279/GIS
 /**
  * Create HTML output for groups
  * @return string
  */
 public function writeGroups($groupList = false)
 {
     if ($groupList == false) {
         $layerView = new LayerView($this->map, false, false);
         $groupList = $layerView->getGroupList();
     }
     $html = "<ul>";
     foreach ($groupList as $grp) {
         $grpName = $grp['name'];
         //$grpDescr = addslashes($grp['description']);
         $grpDescr = $grp['description'];
         $classList = $grp['classList'];
         $numcls = count($classList);
         $html .= "<li id=\"ligrp_{$grpName}\" class=\"tocgrp\">";
         $html .= "<input type=\"checkbox\" name=\"groupscbx\" value=\"{$grpName}\" id=\"ginput_{$grpName}\"/>";
         $html .= "<span class=\"vis\" id=\"spxg_{$grpName}\"><span class=\"grp-title\">{$grpDescr}</span></span>";
         // Add classes
         if ($numcls > 0 && $this->legendStyle == "attached") {
             $html .= $this->writeClasses($grpName, $classList);
         }
         $html .= "</li>";
     }
     $html .= "</ul>";
     //error_log($html);
     return $html;
 }
コード例 #7
0
ファイル: groupsAndLayers.php プロジェクト: sukma279/GIS
/**
 * 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;
}