Example #1
0
 public function generatePreviewMap(array $mbr, $format = 'png', $layergroupHighlight = null)
 {
     try {
         $wmsList = $this->getWmsList();
         // empty($this->wmsList) ? $this->getWmsList(); : $this->wmsList;
         foreach ($wmsList as $i => $wmsService) {
             if (!empty($this->globalWmsParameters)) {
                 $wmsList[$i]['parameters'] = array_merge($wmsList[$i]['parameters'], $this->globalWmsParameters);
             }
             if (!empty($this->wmsParameters[$wmsService['name']])) {
                 $wmsList[$i]['parameters'] = array_merge($wmsList[$i]['parameters'], $this->wmsParameters[$wmsService['name']]);
             }
         }
         if (empty($this->extent)) {
             $this->extent = $this->calculateExtent($mbr);
         }
         if (!empty($layergroupHighlight)) {
             $this->sldHighlight($wmsList, $layergroupHighlight, $this->sldFolderUrl . $layergroupHighlight . '_sld.php?field=' . $this->options['id_field'] . '&id=' . $this->options['id_value']);
         }
         if (!empty($this->additionalHighlights)) {
             foreach ($this->additionalHighlights as $layergroup => $highlights) {
                 foreach ($highlights as $highlightParameters) {
                     $url = empty($highlightParameters['url']) ? $this->sldFolderUrl : $highlightParameters['url'];
                     $this->sldHighlight($wmsList, $layergroup, $url . $layergroup . '_sld.php?field=' . $highlightParameters['id_field'] . '&id=' . $highlightParameters['id_value'], $highlightParameters['exclusive']);
                 }
             }
         }
         // performance boost merging SLD & WMS requests (by theme, complete merge has problems with layerorder)
         if ($this->options['mergeSLD']) {
             $sldList = $this->mergeSLD($wmsList);
         }
         if ($this->options['mergeRequest']) {
             $wmsList = $this->mergeWMSList($wmsList);
         }
         $time_start = microtime(true);
         $preview = new R3OgcMap($this->extent, $this->options['size'], $wmsList);
         $preview->createImage();
         $fileContent = $preview->getCanvas();
         // remove temporary sld files
         if ($this->options['mergeSLD']) {
             foreach ($sldList as $sldFileName) {
                 unlink($sldFileName);
             }
         }
         $time_end = microtime(true);
         $time = $time_end - $time_start;
         // echo "In $time Sekunden Preview estellt\n"; die();
     } catch (Exception $e) {
         throw $e;
     }
     return $fileContent;
 }
Example #2
0
 protected function getMapImage()
 {
     try {
         if (class_exists('R3AppInit')) {
             $elapsedTime = sprintf("elapsed time: %.3f s", microtime(true) - R3AppInit::$startTime);
             ezcLog::getInstance()->log(__METHOD__ . ", {$elapsedTime}, start", ezcLog::DEBUG);
         }
         $this->calculateSizes();
         $this->buildWmsList();
         if ($this->options['scale_mode'] == 'user') {
             $this->calculateExtent();
         } else {
             $this->adaptExtentToSize();
         }
         $r3OgcMap = new R3OgcMap($this->extent, $this->imageSize, $this->wmsList);
         #$wms = $this->createVectorWms();
         #$r3OgcMap->registerWMS($wms);
         #$textWms = $this->drawTextVectors();
         // TODO: draw vector features
         $r3OgcMap->createImage();
         $this->imageFileName = $r3OgcMap->saveImageToTmp('png', $this->options['TMP_PATH'], 'filename');
         if (class_exists('R3AppInit')) {
             $elapsedTime = sprintf("elapsed time: %.3f s", microtime(true) - R3AppInit::$startTime);
             ezcLog::getInstance()->log(__METHOD__ . ", {$elapsedTime}, end", ezcLog::DEBUG);
         }
     } catch (Exception $e) {
         throw $e;
     }
 }