File "download.phtml"
Full path: /www/map/mapserver-extensions/pmapper-4.2.0/download.phtml
File size: 3.07 KiB (3147 bytes)
MIME-type: text/x-php
Charset: utf-8
<?php
/******************************************************************************
*
* Purpose: creates and shows hih resolution map image for download
* Author: Armin Burger
*
******************************************************************************
*
* Copyright (c) 2003-2006 Armin Burger
*
* This file is part of p.mapper.
*
* 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
*
******************************************************************************/
// prevent XSS
if (isset($_REQUEST['PM_INCPHP'])) exit();
require_once("incphp/group.phtml");
require_once("incphp/pmsession.phtml");
require_once("incphp/globals.phtml");
require_once("incphp/common.phtml");
require_once("incphp/map/map.phtml");
require_once("incphp/print/print.phtml");
// GET NEW DPI FOR OUT IMG
if (isset ($_POST["dldpi"]) && in_array($_POST["dldpi"], $_SESSION['dpiLevels'])) {
$imgDPI = $_POST["dldpi"];
} else {
$imgDPI = 300;
}
if (isset ($_POST["imgFormat"])) {
$imgFormat = $_POST["imgFormat"];
} else {
$imgFormat = false;
}
// CALCULATE NEW MAP SIZES
$mapfileDPI = $map->resolution;
$mapW = $_SESSION["mapwidth"];
$mapH = $_SESSION["mapheight"];
$dpiFactor = $imgDPI/$mapfileDPI;
$newMapW = round($mapW * $dpiFactor);
$newMapH = round($mapH * $dpiFactor);
// APPLY TO MAP
$map->set("width", $newMapW);
$map->set("height", $newMapH);
$map->set("resolution", $imgDPI);
$scale = round($_SESSION["geo_scale"]);
// APPLY ON VISIBLE GROUPS/LAYERS
$groups = $_SESSION["groups"];
// call function
PMCommon::setGroups($map, $groups, 0, 1);
/*
// Show also feature highlight
// ADD RESULTLAYERS
if (isset($_SESSION["resultlayers"])) {
$resultlayers = $_SESSION["resultlayers"];
foreach ($resultlayers as $reslayer => $shpindexes) {
addResultLayer($map, $reslayer, $shpindexes);
}
}
*/
// GET MAP IMAGE URL
$printMap = new PrintMap($map, $newMapW, $newMapH, $scale, "dl", $imgDPI, $imgFormat);
$printUrlList = $printMap->returnImgUrlList();
$printmapUrl = $printUrlList[0];
if ($imgFormat):
header('Content-type: image/tiff');
header('Content-Disposition: attachment; filename="mapdownload.tif"');
readfile($printmapUrl);
else:
$printlegUrl = $printUrlList[1];
?>
<HTML>
<HEAD>
<TITLE>Download</TITLE>
</HEAD>
<BODY>
<?php echo ("<img src='$printmapUrl' border=0> <br><br> <!-- <img src='$printlegUrl' border=0> -->") ?>
</BODY>
</HTML>
<?php
endif;
?>