/** * CREATE MAP IMAGE */ public function pmap_createMapImage() { // use layers with complex queries that are too long to select results $oldDatas = array(); $numLayers = $this->map->numlayers; for ($iLayer = 0; $iLayer < $numLayers; $iLayer++) { $msLayer = $this->map->getLayer($iLayer); $newdata = $msLayer->getMetaData('PM_RESULT_DATASUBSTITION'); if ($newdata != '') { $oldDatas[$msLayer->name] = $msLayer->data; $msLayer->set('data', $newdata); } } // Set image format according to settings $this->pmap_setImgFormat(); // DRAW MAP AND SET GEO EXTENT (IN MAP UNITS) IN SID FOR SUBSEQUENT ZOOM ACTIONS // $mapImg = $this->map->draw(); // CHECK iF THERE'S AN XY-LAYER AND THEN DRAW IT if ($_SESSION["existsXYLayer"]) { $this->pmap_drawXYLayer($mapImg); } // write old geoextent to var before changing $this->OLDGEOEXT = $this->GEOEXT; //error_log($this->OLDGEOEXT); // convert numbers for GEOEXT and geo_scale to string // to avoid saving numbers as full float number in SID $this->GEOEXT["minx"] = strval($this->map->extent->minx); $this->GEOEXT["miny"] = strval($this->map->extent->miny); $this->GEOEXT["maxx"] = strval($this->map->extent->maxx); $this->GEOEXT["maxy"] = strval($this->map->extent->maxy); $this->geo_scale = $this->map->scaledenom; // PRODUCE MAP, REFERENCE AND SCALEBAR IMAGE // //$this->mapURL = $mapImg->saveWebImage(); $this->mapURL = PMCommon::mapSaveWebImage($this->map, $mapImg); $scalebarImg = $this->map->drawScaleBar(); //$this->scalebarURL = $scalebarImg->saveWebImage(); $this->scalebarURL = PMCommon::mapSaveWebImage($this->map, $scalebarImg); if (isset($_SESSION['ul'])) { //error_log($_SESSION['ul']); //$urlLayer = new URL_Layer($this->map, $mapImg); } PMCommon::freeMsObj($mapImg); PMCommon::freeMsObj($scalebarImg); // reset data tag foreach ($oldDatas as $layerName => $oldData) { $msLayer = $this->map->getLayerByName($layerName); if ($msLayer) { $msLayer->set('data', $oldData); } } }
protected function drawImages($printType, $imgDPI, $imgFormat, $prefmap) { // CREATE MAP IMAGE AND PASTE SCALEBAR AND REFERENCE MAP switch ($printType) { // HTML OUTPUT case "html": // allow to redefine images drawing $this->map->set("width", $this->mapW); $this->map->set("height", $this->mapH); // $this->map->set("resolution", 96); $images = $this->drawScaleBarAndRefMap($printType, $imgDPI); $sbarImg = $images['sbarImg']; $refImg = $images['refImg']; $this->pmap_setImgFormat(true); $mapImg = $this->map->draw(); // CHECK iF THERE'S AN XY-LAYER AND THEN DRAW IT if ($this->existsXYLayer) { $this->pmap_drawXYLayer($mapImg); } //$mapImg->pasteImage($sbarImg, 0, 3, $this->mapH-25); //if ($prefmap) $mapImg->pasteImage($refImg, -1); //$this->imgUrlList[] = $mapImg->saveWebImage(); $this->imgUrlList[] = PMCommon::mapSaveWebImage($this->map, $mapImg); $this->imgUrlList[] = PMCommon::mapSaveWebImage($this->map, $refImg, true); $this->imgUrlList[] = PMCommon::mapSaveWebImage($this->map, $sbarImg); PMCommon::freeMsObj($mapImg); break; // PDF OUTPUT // PDF OUTPUT case "pdf": // Increase size and resolution for better print quality (factor set in config.ini -> pdfres) // Note: resolution has to be increased, too, to keep scale dependency of layers $pdfres = $_SESSION["pdfres"]; $this->map->set("width", $this->mapW * $pdfres); $this->map->set("height", $this->mapH * $pdfres); $this->map->set("resolution", 96 * $pdfres); // MS < 6 // Increase Label size according to magnificion for PDF output $this->increaseLabels($pdfres); $images = $this->drawScaleBarAndRefMap($printType, $imgDPI, $pdfres); $sbarImg = $images['sbarImg']; $refImg = $images['refImg']; $this->pmap_setImgFormat(true); $mapImgHR = $this->map->draw(); // CHECK iF THERE'S AN XY-LAYER AND THEN DRAW IT if ($this->existsXYLayer) { $this->pmap_drawXYLayer($mapImgHR); } /*$this->imgUrlList[] = $mapImgHR->saveWebImage(); $this->imgUrlList[] = $refImg->saveWebImage(); $this->imgUrlList[] = $sbarImg->saveWebImage();*/ $this->imgUrlList[] = PMCommon::mapSaveWebImage($this->map, $mapImgHR); $this->imgUrlList[] = PMCommon::mapSaveWebImage($this->map, $refImg, true); //$this->imgUrlList[] = $refImg->saveWebImage(); $this->imgUrlList[] = PMCommon::mapSaveWebImage($this->map, $sbarImg); PMCommon::freeMsObj($mapImgHR); break; // DOWNLOAD HIGH RESOLUTION IMAGE // DOWNLOAD HIGH RESOLUTION IMAGE case "dl": // Increase Label size according to DPI $factor = round($imgDPI / 96); $this->increaseLabels($factor); $images = $this->drawScaleBarAndRefMap($printType, $imgDPI); $sbarImg = $images['sbarImg']; $refImg = $images['refImg']; //$this->map->selectOutputFormat("jpeg"); if ($imgFormat) { $this->map->selectOutputFormat($imgFormat); } else { $this->pmap_setImgFormat(true); } $mapImgHR = $this->map->draw(); // CHECK iF THERE'S AN XY-LAYER AND THEN DRAW IT if ($this->existsXYLayer) { $this->pmap_drawXYLayer($mapImgHR); } // GeoTIFF output if ($imgFormat) { $tmpFileName = str_replace('\\', '/', $this->map->web->imagepath) . substr(SID, 10) . ".tif"; $mapImgHR->saveImage($tmpFileName, $this->map); $this->imgUrlList[] = $tmpFileName; // JPG or PNG output } else { $this->imgUrlList[] = PMCommon::mapSaveWebImage($this->map, $mapImgHR); $legImg = $this->map->drawLegend(); $this->imgUrlList[] = PMCommon::mapSaveWebImage($this->map, $legImg); PMCommon::freeMsObj($legImg); } PMCommon::freeMsObj($mapImgHR); break; } PMCommon::freeMsObj($refImg); PMCommon::freeMsObj($sbarImg); }
/** * draw refmap image */ public function drawRefMap($minx, $miny, $maxx, $maxy, $width, $height, $useAlternatFormatForMS6) { $this->activateLayers(); // do not use RGBA in MS 6 if refmap will be used in mapObj::drawReferenceMap (transparency not supported) if ($useAlternatFormatForMS6 && $this->msVersion >= 6) { $this->internalMap->selectOutputFormat($this->altOutputFormat); } else { $this->internalMap->selectOutputFormat($this->outputFormat); } $this->internalMap->setSize($width, $height); $this->internalMap->setExtent($minx, $miny, $maxx, $maxy); $refMapImg = $this->internalMap->draw(); $this->refMapURL = PMCommon::mapSaveWebImage($this->internalMap, $refMapImg); PMCommon::freeMsObj($refMapImg); $this->refMapImage = str_replace($this->internalMap->web->imageurl, $this->internalMap->web->imagepath, $this->refMapURL); }