Esempio n. 1
0
 /**
  * Register added dynamic layers in p.mapper group/layer objects
  * is called from initDynLayers()
  */
 protected function registerDynLayers($layerNames, $rewriteLegend)
 {
     $allGroups = array_merge($_SESSION['allGroups'], $layerNames);
     $_SESSION['allGroups'] = array_unique($allGroups);
     if ($rewriteLegend) {
         $initMap = new Init_map($this->map, false, false, $_SESSION['gLanguage']);
         $initMap->createLegendList();
     }
     $iG = new Init_groups($this->map, $allGroups, $_SESSION['language'], false);
     $iG->createGroupList();
 }
Esempio n. 2
0
 public function initDynLayers($rewriteLegend = true)
 {
     $this->createDynLayers();
     require_once $_SESSION['PM_INCPHP'] . "/initgroups.php";
     $allGroups = array_merge($_SESSION['allGroups'], $this->dynLayerList);
     $_SESSION['allGroups'] = array_unique($allGroups);
     if ($rewriteLegend) {
         require_once $_SESSION['PM_INCPHP'] . "/init/initmap.php";
         $initMap = new Init_map($this->map, false, false, $_SESSION['gLanguage']);
         $initMap->createLegendList();
     }
     $iG = new Init_groups($this->map, $allGroups, $_SESSION['language'], false);
     $iG->createGroupList();
 }
Esempio n. 3
0
 /**
  * Initilaize 'map' section from config
  */
 private function _initMap()
 {
     $iniMap = $this->ini['map'];
     $this->iniToSession("layerAutoRefresh", $iniMap['layerAutoRefresh']);
     $this->iniToSession("sliderMax", $iniMap['sliderMax']);
     $this->iniToSession("sliderMin", $iniMap['sliderMin']);
     //*** Categories
     $categories = array();
     $categoriesClosed = array();
     // categories defined
     if (isset($iniMap['categories']) && isset($iniMap['categories']['category'])) {
         $iniCat = $iniMap['categories']['category'];
         if (array_key_exists('name', $iniCat)) {
             $descr = $iniCat['description'] ? $iniCat['description'] : $iniCat['name'];
             $categories[$iniCat['name']] = array("description" => $descr, "groups" => (array) $iniCat['group']);
         } else {
             foreach ($iniCat as $cat) {
                 $descr = array_key_exists('description', $cat) ? $cat['description'] : $cat['name'];
                 $categories[$cat['name']] = array("description" => $descr, "groups" => (array) $cat['group']);
                 // "closed = false" --> not closed!
                 if (array_key_exists('closed', $cat) && $cat['closed'] === "true") {
                     $categoriesClosed[] = $cat['name'];
                 }
             }
         }
     }
     $_SESSION['categories'] = $categories;
     $_SESSION['categoriesClosed'] = $categoriesClosed;
     //*** AllGroups
     $mapGrps = $this->map->getAllGroupNames();
     $mapLays = $this->map->getAllLayerNames();
     $GrpLay = array_merge($mapGrps, $mapLays);
     if (isset($iniMap["allGroups"])) {
         $allGroups = (array) $iniMap['allGroups']['group'];
     } else {
         $allGroups = $this->map->getAllGroupNames();
         foreach ($mapLays as $ml) {
             if (!$this->map->getLayerByName($ml)->group) {
                 $allGroups[] = $ml;
             }
         }
     }
     $_SESSION['allGroups'] = $allGroups;
     $_SESSION['allGroups0'] = $allGroups;
     //*** default groups, visible at start
     // without definition, ALL groups will be set visible
     // Check if layers are set externally via URL
     if (isset($_REQUEST['dg'])) {
         $defGroupsGET = explode(',', $_REQUEST['dg']);
         $defGroups = array();
         foreach ($defGroupsGET as $gG) {
             if (in_array($gG, $allGroups)) {
                 $defGroups[] = $gG;
             }
         }
         // if no valid layers supplied, take first from ini
         if (count($defGroups) < 1) {
             $defGroups = array($allGroups[0]);
         }
         // Else take them from config settings
     } elseif (isset($iniMap['defGroups'])) {
         // only groups available in defGroups and categories
         $defGroups = array();
         // defGroups defined in config settings
         $defGroupsConfig = isset($iniMap['defGroups']['group']) ? (array) $iniMap['defGroups']['group'] : array();
         // keep only those available in categories
         foreach ($defGroupsConfig as $g) {
             if (!in_array($g, $GrpLay)) {
                 pm_logDebug(0, "P.MAPPER-ERROR: Layer/Group '{$g}' not existing. Check 'config_{$_SESSION['config']}.xml' file definition for section 'map.defGroups'.");
             } else {
                 $defGroups[] = $g;
             }
         }
         // Else take all
     } else {
         $defGroups = array();
         //$allGroups;
     }
     $_SESSION['defGroups'] = $defGroups;
     //** autoidentifygropus: layer where to apply auto_indentify() function ***/
     if (isset($iniMap['autoIdentifyGroups'])) {
         $autoIdentifyGroups = (array) $iniMap['autoIdentifyGroups']['group'];
         // Check for errors
         foreach ($autoIdentifyGroups as $g) {
             if (!in_array($g, $GrpLay)) {
                 pm_logDebug(1, "P.MAPPER-ERROR: Layer/Group '{$g}' not existing. Check 'config_{$_SESSION['config']}.xml' file definition for section 'map.autoIdentifyGroups'.");
             }
         }
         $_SESSION['autoIdentifyGroups'] = $autoIdentifyGroups;
     }
     /*** LAYERS DISABLING EACH OTHER ***/
     if (isset($iniMap['mutualDisableList'])) {
         $mutualDisableList = (array) $iniMap['mutualDisableList']['group'];
         foreach ($mutualDisableList as $mg) {
             if (!in_array($mg, $allGroups)) {
                 pm_logDebug(1, "P.MAPPER-ERROR: Layer/Group '{$mg}' not existing. Check 'config_{$_SESSION['config']}.xml' file definition for section 'map.mutualDisableList'.");
                 $mutualDisableList = array();
             }
         }
     } else {
         $mutualDisableList = array();
     }
     $_SESSION['mutualDisableList'] = $mutualDisableList;
     /*** LAYERS CAUSING MAP TO SWITCH TO ALTERNATIVE IMAGE FORMAT ***/
     if (isset($iniMap['altImgFormatLayers'])) {
         $altImgFormatLayers = (array) $iniMap['altImgFormatLayers']['layer'];
         foreach ($altImgFormatLayers as $mg) {
             if (!@($mapLayer = $this->map->getLayerByName($mg))) {
                 pm_logDebug(0, "P.MAPPER-ERROR: Layer/Group '{$mg}' not existing. Check 'config_{$_SESSION['config']}.xml' file definition for section 'map.altImgFormatLayers'.", 0);
             }
         }
     } else {
         $altImgFormatLayers = 0;
     }
     $_SESSION['altImgFormatLayers'] = $altImgFormatLayers;
     /*** Specify GROUP objects ***/
     require_once PM_INCPHP . "/initgroups.php";
     $iG = new Init_groups($this->map, $allGroups, $this->gLanguage, $this->ini);
     $iG->createGroupList();
 }
Esempio n. 4
0
function updateGroupList($map)
{
    // get original opacities:
    // this require should be done before session_start!!!
    //require_once($_SESSION['PM_INCPHP'] . '/group.php');
    $grouplist = $_SESSION['grouplist'];
    $opacities = array();
    foreach ($grouplist as $grp) {
        $glayerList = $grp->getLayers();
        foreach ($glayerList as $glayer) {
            $opacities[$glayer->getLayerName()] = $glayer->getOpacity();
        }
    }
    // change SESSION['grouplist']:
    require_once $_SESSION['PM_INCPHP'] . '/initgroups.php';
    $iG = new Init_groups($map, $_SESSION['allGroups'], $_SESSION['gLanguage'], true);
    $iG->createGroupList();
    //restore opacity:
    $grouplist = $_SESSION['grouplist'];
    foreach ($grouplist as $grp) {
        $glayerList = $grp->getLayers();
        foreach ($glayerList as $glayer) {
            $name = $glayer->getLayerName();
            if (isset($opacities[$name])) {
                $opacity = $opacities[$name];
                $glayer->setOpacity($opacity);
            }
        }
    }
}
Esempio n. 5
0
 /**
  * 
  * Update legend and pmapper variables:
  * 
  * - add or remove layers to $_SESSION['allGroups']
  * - create legend (call Init_map::createLegendList)
  * - update groups and glayers definitions (instanciate Init_groups)
  */
 private function updateToc($dynLayers)
 {
     $allGroups = $_SESSION['allGroups'];
     $initialCount = count($allGroups);
     if ($initialCount > 0) {
         foreach ($dynLayers as $dynLayer) {
             if ($layerName = $dynLayer->getLayerName()) {
                 // update the groups lists:
                 if ($dynLayer->hasFeatures()) {
                     $allGroups = array_merge($allGroups, array($layerName));
                 } else {
                     $newGroups = array();
                     foreach ($allGroups as $groupName) {
                         if ($groupName != $layerName) {
                             $newGroups[] = $groupName;
                         }
                     }
                     $allGroups = $newGroups;
                 }
             }
             $allGroups = array_unique($allGroups);
         }
         $_SESSION['allGroups'] = $allGroups;
         // get original opacities:
         // this require should be done before session_start!!!
         //			require_once($_SESSION['PM_INCPHP'] . '/group.php');
         $grouplist = $_SESSION['grouplist'];
         $opacities = array();
         foreach ($grouplist as $grp) {
             // to avoid bad incphp/group.php inclusion, like in map.phtml for instance
             // for instance :
             // refresh a page
             // -> call map.phtml
             // -> session_start(), then include group.php
             // -> error : __PHP_Imcomplete_Class
             if (is_object($grp)) {
                 $glayerList = $grp->getLayers();
                 foreach ($glayerList as $glayer) {
                     $opacities[$glayer->getLayerName()] = $glayer->getOpacity();
                 }
             }
         }
         // update legend:
         if ($initialCount != count($allGroups)) {
             require_once $_SESSION['PM_INCPHP'] . '/init/initmap.php';
             $initMap = new Init_map($this->map, false, false, $_SESSION['gLanguage']);
             $initMap->createLegendList();
         }
         // update groups and glayer definitions
         require_once $_SESSION['PM_INCPHP'] . '/initgroups.php';
         $iG = new Init_groups($this->map, $allGroups, $_SESSION['gLanguage'], true);
         $iG->createGroupList();
         // restore opacity:
         $grouplist = $_SESSION['grouplist'];
         foreach ($grouplist as $grp) {
             $glayerList = $grp->getLayers();
             foreach ($glayerList as $glayer) {
                 $name = $glayer->getLayerName();
                 if (isset($opacities[$name])) {
                     $opacity = $opacities[$name];
                     $glayer->setOpacity($opacity);
                 }
             }
         }
     }
 }