private function url_createLayer() { if (!is_file($_SESSION['PM_TPL_MAP_FILE'])) { error_log("P.MAPPER ERROR: cannot find template map. Check INI settings for 'tplMapFile'"); return false; } $tplMap = ms_newMapObj($_SESSION['PM_TPL_MAP_FILE']); $poiLayer = $tplMap->getLayerByName("poi"); $txtLayer = ms_newLayerObj($this->map, $poiLayer); $txtLayer->set("name", "url_txtlayer"); $txtLayer->set("type", 0); $txtLayer->set("status", MS_ON); $url_points = $_SESSION['url_points']; foreach ($url_points as $upnt) { // Create line, add xp point, create shape and add line and text, add shape to layer //$pointList = explode(",", $f); $px = $upnt[0]; $py = $upnt[1]; $txt = $upnt[2]; $newLine = ms_newLineObj(); $newLine->addXY($px, $py); $newShape = ms_newShapeObj(0); $newShape->add($newLine); $newShape->set("text", $txt); $txtLayer->addFeature($newShape); } }
function __construct($map_file = "", $perfil = "", $locaplic = "", $urli3geo = "", $editores = "", $idioma = "pt", $filtro = "") { include dirname(__FILE__) . "/../ms_configura.php"; $this->postgis_mapa = $postgis_mapa; $perfil = str_replace(" ", ",", $perfil); $this->perfil = explode(",", $perfil); $this->locaplic = $locaplic; $this->urli3geo = $urli3geo; $this->idioma = $idioma; $this->filtro = $filtro; if ($map_file != "" && file_exists($map_file)) { $this->mapa = ms_newMapObj($map_file); substituiConObj($this->mapa, $postgis_mapa); $this->arquivo = $map_file; if ($this->mapa) { $c = $this->mapa->numlayers; for ($i = 0; $i < $c; ++$i) { $this->layers[] = $this->mapa->getlayer($i); } } } // //verifica o usuario logado esta cadastrado como um dos publicadores //editores podem ver as coisas marcadas como não publicado //no sistema de administração // $this->editor = false; $this->editores = ""; $this->editor = $this->verificaPapelSessao(3); }
function __construct($map_file, $locaplic = "") { include dirname(__FILE__) . "/../ms_configura.php"; $this->postgis_mapa = $postgis_mapa; if (file_exists($locaplic . "/funcoes_gerais.php")) { include_once $locaplic . "/funcoes_gerais.php"; } else { include_once "funcoes_gerais.php"; } $this->mapa = ms_newMapObj($map_file); substituiConObj($this->mapa, $postgis_mapa); $this->arquivo = str_replace(".map", "", $map_file) . ".map"; }
function drawKCCI($extents) { $width = "150"; $height = "150"; /** ----------------------- */ $map = ms_newMapObj("mosaic.map"); $map->set("width", $width); $map->set("height", $height); $map->setextent($extents[0], $extents[1], $extents[2], $extents[3]); $map->setProjection("init=epsg:4326"); $counties = $map->getlayerbyname("counties_unproj"); $counties->set("status", MS_ON); $radarL = $map->getlayerbyname("KCCI"); $radarL->set("status", MS_ON); $img = $map->prepareImage(); $radarL->draw($img); $counties->draw($img); $url = $img->saveWebImage(MS_PNG, 0, 0, -1); return $url; }
function __construct($map_file, $tema = "", $locaplic = "", $ext = "") { include dirname(__FILE__) . "/../ms_configura.php"; $this->postgis_mapa = $postgis_mapa; include_once dirname(__FILE__) . "/funcoes_gerais.php"; $this->locaplic = $locaplic; $this->mapa = ms_newMapObj($map_file); substituiConObj($this->mapa, $postgis_mapa); $this->arquivo = str_replace(".map", "", $map_file) . ".map"; $this->layer = ""; if ($tema != "" && @$this->mapa->getlayerbyname($tema)) { $this->layer = $this->mapa->getlayerbyname($tema); } $this->nome = $tema; if ($ext && $ext != "") { $e = explode(" ", $ext); $extatual = $this->mapa->extent; $extatual->setextent(min($e[0], $e[2]), min($e[1], $e[3]), max($e[0], $e[2]), max($e[1], $e[3])); } }
function markerclusterEstilos($map_file, $layer, $tipoEstilos) { if ($tipoEstilos == "default") { $tipoEstilos = '{"ponto":{url : i3GEO.configura.locaplic + "/imagens/google/symbol_blank.png",height : 20,width : 20},"estilos":[{url : i3GEO.configura.locaplic + "/imagens/google/m1.png",height : 53,width : 53},{url : i3GEO.configura.locaplic + "/imagens/google/m2.png",height : 56,width : 56},{url : i3GEO.configura.locaplic + "/imagens/google/m3.png",height : 66,width : 66},{url : i3GEO.configura.locaplic + "/imagens/google/m4.png",height : 78,width : 78},{url : i3GEO.configura.locaplic + "/imagens/google/m5.png",height : 90,width : 90}]}'; } else { $tipoEstilos = array(); $mapa = ms_newMapObj($map_file); $l = $mapa->getlayerbyname($layer); $nc = $l->numclasses; // a primeira classe e o ponto que nao entra no cluster for ($c = 1; $c < $nc; $c++) { $classe = $l->getclass($c); $estilo = $classe->getstyle(0); $tipoEstilos[] = array("url" => $estilo->symbol, "height" => $estilo->size, "width" => $estilo->size); } $classe = $l->getclass(0); $estilo = $classe->getstyle(0); $tipoEstilos = json_encode(array("ponto" => array("url" => $estilo->symbol, "height" => $estilo->size, "width" => $estilo->size), "estilos" => $tipoEstilos)); } return $tipoEstilos; }
function heatmapGradiente($map_file, $layer, $tipoGradiente) { if ($tipoGradiente == "default") { $gradiente = '{"gradient":{"0.45" : "rgb(0,0,255)","0.55" : "rgb(0,255,255)","0.65" : "rgb(0,255,0)","0.95" : "yellow","1.0" : "rgb(255,0,0)"}}'; } else { $gradiente = array(); $mapa = ms_newMapObj($map_file); $l = $mapa->getlayerbyname($layer); $nc = $l->numclasses; for ($c = 0; $c < $nc; $c++) { $classe = $l->getclass($c); $estilo = $classe->getstyle(0); $nome = $classe->name; $cor = $estilo->color; $scor = "rgb(" . $cor->red . "," . $cor->green . "," . $cor->blue . ")"; $gradiente[$nome] = $scor; } //echo $map_file;exit; $gradiente = json_encode(array("gradient" => $gradiente)); } return $gradiente; }
function incluiWMC() { global $map_file, $arquivo; $mapa = ms_newMapObj($map_file); $proj = $mapa->getprojection(); $mapa->loadMapContext($arquivo, "MS_TRUE"); $layers = $mapa->getalllayernames(); foreach ($layers as $nome) { $l = $mapa->getlayerbyname($nome); $con = $l->connectiontype; if (($con == 7 || $con == 9) && $l->getmetadata("tema") == "") { if ($l->getmetadata("wms_title") != "") { $l->setmetadata("tema", $l->getmetadata("wms_title")); } else { $l->setmetadata("tema", $l->getmetadata("wms_name")); } } } $mapa->setprojection($proj); $mapa->save($map_file); echo "Arquivo carregado com sucesso!"; }
function Main($map) { $GLOBALS["goMap"] = ms_newMapObj("{$map}"); //batas koordinat seluruh peta, untuk tool 'zoom all' $GLOBALS["gfMinX"] = (double) $GLOBALS["goMap"]->extent->minx; $GLOBALS["gfMinY"] = (double) $GLOBALS["goMap"]->extent->miny; $GLOBALS["gfMaxX"] = (double) $GLOBALS["goMap"]->extent->maxx; $GLOBALS["gfMaxY"] = (double) $GLOBALS["goMap"]->extent->maxy; //set nilai $aVars dengan nilai parameter URL if (sizeof($_POST) > 0) { $aVars = $_POST; } else { if (sizeof($_GET) > 0) { $aVars = $_GET; } else { $aVars = array(); } } //tool navigasi default: zoom in $GLOBALS["gszCurrentTool"] = "ZOOM_IN"; $GLOBALS["gShowQueryResults"] = FALSE; //proses parameter URL ProcessURLArray($aVars); }
if (array_search("MapScript", $exts) != TRUE) { if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) { if (!@dl('php_mapscript_48.dll')) { dl('php_mapscript.dll'); } } else { dl('php_mapscript.so'); } } require dirname(__FILE__) . "/../../classesphp/funcoes_gerais.php"; $nomes = nomeRandomico(); $temp = str_replace(".map", "xxx.map", $map_file); $map = ms_newMapObj($map_file); $map->save($temp); substituiCon($temp, $postgis_mapa); $map = ms_newMapObj($temp); substituiCon($temp, $postgis_mapa); $w = $map->width; $h = $map->height; $legenda = $map->legend; $legenda->set("status", MS_EMBED); //altera o nome das classes vazias $temas = $map->getalllayernames(); foreach ($temas as $tema) { $layer = $map->getlayerbyname($tema); if ($layer->data != "" && strtolower($layer->getmetadata("escondido")) != "sim" && strtolower($layer->getmetadata("tema")) != "nao") { if ($layer->numclasses > 0) { $classe = $layer->getclass(0); if ($classe->name == "" || $classe->name == " ") { $classe->set("name", $layer->getmetadata("tema")); }
$round = array("prec" => 2, "gdd50" => 0, "gdd32" => 0, "et" => 2, "sgdd50" => 0, "sgdd52" => 0, "sdd86" => 0, "srad" => 0); $today = time(); if ($gs_end >= $today) { $gs_end = $today; } $emonth = strftime("%m", $gs_end); $eday = strftime("%d", $gs_end); $smonth = strftime("%m", $gs_start); $sday = strftime("%d", $gs_start); $varDef = array("gdd50" => "Growing Degree Days (base=50)", "gdd32" => "Growing Degree Days (base=32)", "et" => "Potential Evapotranspiration", "prec" => "Precipitation", "srad" => "Solar Radiation (langleys)", "sgdd50" => "Soil Growing Degree Days (base=50)", "sgdd52" => "Soil Growing Degree Days (base=52)", "sdd86" => "Stress Degree Days (base=86)"); $rnd = array("gdd50" => 0, "gdd32" => 0, "et" => 2, "c11" => 2, "prec" => 2, "srad" => 0, "sgdd50" => 0, "sgdd52" => 0, "sdd86" => 0); $myStations = $ISUAGcities; $height = $height; $width = $width; $proj = "init=epsg:26915"; $map = ms_newMapObj("../../../../data/gis/base26915.map"); $map->setsize($width, $height); $map->setProjection($proj); $map->setextent(175000, 4440000, 775000, 4890000); $counties = $map->getlayerbyname("counties"); $counties->set("status", MS_ON); $snet = $map->getlayerbyname("station_plot"); $snet->set("status", MS_ON); $iards = $map->getlayerbyname("iards"); $iards->set("status", MS_ON); $bar640t = $map->getlayerbyname("bar640t"); $bar640t->set("status", MS_ON); $ponly = $map->getlayerbyname("pointonly"); $ponly->set("status", MS_ON); $states = $map->getlayerbyname("states"); $states->set("status", MS_ON);
<?php include "../../config/settings.inc.php"; include "../../include/database.inc.php"; $con = iemdb("postgis"); $sql = "SELECT max(valid) as valid from roads_current"; $rs = pg_query($con, $sql); $row = pg_fetch_array($rs, 0); $valid = substr($row["valid"], 0, 16); $map = ms_newMapObj('roads.map'); //$map->setProjection("init=epsg:4326"); $map->setProjection("init=epsg:26915"); $map->selectOutputFormat("jpeg"); $map->setextent(122487.56, 4443095.235, 809431.656, 4919662.5); $map->set("width", 720); $map->set("height", 496); $img = $map->prepareImage(); $background = $map->getlayerbyname("kwwlback"); $background->set("status", MS_ON); $background->set("data", "images/26915/kcau.tif"); $background->draw($img); //$counties = $map->getlayerbyname("counties"); //$counties->set("status", MS_ON); //$counties->draw($img); //$states = $map->getlayerbyname("states"); //$states->set("status", MS_ON); //$states->draw($img); $roads = $map->getlayerbyname("roads"); $roads->set("status", MS_ON); if (isset($_GET["extreme"])) { $roads->set("data", "geom from (select b.type as rtype, b.int1, b.oid as boid, b.segid, c.cond_code, b.geom from roads_base b, roads_2007_log c WHERE b.segid = c.segid and c.valid = '2007-03-02 00:11' and b.type > 1 ORDER by b.segid DESC) as foo using UNIQUE boid using SRID=26915");
} elseif (isset($_SESSION['rq_lei_f_idcat'])) { $_REQUEST['rq_lei_f_idcat']=$_SESSION['rq_lei_f_idcat']; }*/ // ======================================================================== // special hack: si paramètre spécial spcsc25=tux129 pass? en get (par l'url) // utilise un fichier map specifique limousinhck.map) $mapfile = PROOT . "/maps/{$mapfile}"; if (!empty($_REQUEST['spcsc25'])) { if ($_REQUEST['spcsc25'] == "tux129") { $_SESSION['spcsc25'] = "tux129"; } else { unset($_SESSION['spcsc25']); } } $mapfile = !empty($_SESSION['spcsc25']) ? PROOT . "/maps/limousinhck.map" : $mapfile; $e_map = ms_newMapObj($mapfile); // ces param?tres sont r?cup?r?s par d?faut dans le mapfile static // ils seront maj si la variable extent est d?finie // celle-ci est pass?e en hidden $extminx = $extminxmf = $e_map->extent->minx; $extminy = $extminymf = $e_map->extent->miny; $extmaxx = $extmaxxmf = $e_map->extent->maxx; $extmaxy = $extmaxymf = $e_map->extent->maxy; // fonction qui d?sactivait dans le mapfile toutes les couches qui // ne font pas partie du groupe "fond" // Pourquoi ????? /*$lay = array("fond"); $layers = $e_map->getAllGroupNames(); foreach ($layers as $l) { $maplayer[] = $l; $tl = $e_map->getLayersIndexByGroup($l);
if (getenv("HTTP_IF_MODIFIED_SINCE") == gmdate("D, d M Y H:i:s", $cache_time) . " GMT") { header("HTTP/1.0 304 Not Modified"); $send_body = false; } //more headers header("Expires: " . gmdate("D, d M Y H:i:s", $cache_time + $expires) . " GMT"); header("Cache-Control: max-age={$expires}, must-revalidate"); //header('Content-Length: ' . strlen($body)); //if we're not cacheing if ($send_body) { readfile($legendIconCacheFile); } exit; } } $oMap = ms_newMapObj($_SESSION['maps'][$mapName]); $oLayer = $oMap->getLayerByName($REQUEST_VARS['layername']); $oClass = $oLayer->getClass($REQUEST_VARS['classindex']); $width = $oMap->legend->keysizex; $height = $oMap->legend->keysizey; if ($width <= 0) { $width = 16; } if ($height <= 0) { $height = 16; } $oImg = $oClass->createLegendIcon($width, $height); /* TODO: can we figure out what the content type is? */ header('Content-type: image/png'); if ($cacheLegendIcons) { $oImg->saveImage($legendIconCacheFile);
$nomeMap = $locaplic . "/temas/" . $tema . ".map"; } else { if (file_exists($tema)) { $nomeMap = $tema; } else { // acontece caso o mapfile tenha sido gerado na pasta // temporaria por algum sistema if (file_exists($dir_tmp . "/" . $tema . ".map")) { $nomeMap = $dir_tmp . "/" . $tema . ".map"; } } } if ($nomeMap != "") { $layersNomes = array(); $layers = array(); $maptemp = @ms_newMapObj($nomeMap); if ($maptemp) { $nlayers = $maptemp->numlayers; for ($i = 0; $i < $nlayers; ++$i) { $layern = $maptemp->getLayer($i); // //verifica se o layer contem ferramentas parametrizadas // foreach ($listaFerramentas as $lf) { $meta = $layern->getmetadata($lf); if ($meta != "") { $ferramentas[] = "'" . $lf . "':" . $meta; } } $ferramentas = '{' . implode(",", $ferramentas) . '}'; if ($layern->getmetadata("PLUGINI3GEO") != "") {
function sld() { if (!$this->layer) { //pega o arquivo na pasta temas pois pode ser que esteja tentando gerar o sld diretamente desse arquivo ja que layer nao foi definido $mapa = ms_newMapObj($this->locaplic . "/temas/" . $this->tema . ".map"); $this->layer = $mapa->getlayerbyname($this->tema); } $this->layer->set("status", MS_DEFAULT); return $this->layer->generateSLD(); }
function addLayer($szValue) { global $mapName; global $gwmsServiceTitle; $szReturn->addedLayer = false; // adding a layer from the atlas if ($_REQUEST["layertype"] == 'atlas') { $oMap = ms_newMapObj($_SESSION['maps'][$mapName]); $oCatalogMapFile = ms_newMapObj(APP_LAYER_CATALOG); for ($i = 0; $i < $oCatalogMapFile->numlayers; $i++) { $oLayer = $oCatalogMapFile->getLayer($i); if ($oLayer->name == $_REQUEST["layername"] && $oLayer->group == $_REQUEST["group"]) { //found layer clone it. ms_newLayerObj($oMap, $oLayer); $szReturn->addedLayer = true; } } // save map file. $oMap->save($_SESSION['maps'][$mapName]); } // adding a layer from a wms server if ($_REQUEST["layertype"] == 'wms') { $oMap = ms_newMapObj($_SESSION['maps'][$mapName]); $oLayer = ms_newLayerObj($oMap); if ($_REQUEST["metadataurl"]) { $metadataurl = $_REQUEST["metadataurl"]; } else { $join = strpos($_REQUEST["servername"], "?") ? "&" : "?"; $metadataurl = $_REQUEST["servername"] . $join . "request=GetCapabilities&service=WMS&version=1.1.1"; } $oLayer->set("name", $_REQUEST["layername"]); $oLayer->set("status", MS_ON); //$oLayer->set("connectiontype",MS_WMS); // in mapserver 5.4 we need to set the connection type with the method "setConnectionType" $oLayer->setConnectionType(MS_WMS); $oLayer->set("connection", $_REQUEST["servername"]); $oLayer->set("type", MS_LAYER_RASTER); $oLayer->setMetaData("legendLabel", $_REQUEST["owstitle"]); $aSRS = explode(" ", $_REQUEST["srs"]); $oLayer->setMetaData("ows_name", $_REQUEST["layername"]); $oLayer->setMetaData("ows_format", $_REQUEST["imageFormat"]); $oLayer->setMetaData("ows_server_version", "1.1.1"); $oLayer->setMetaData("ows_srs", $aSRS[0]); $oLayer->setMetaData("wms_metadataurl_href", $metadataurl); $oLayer->setMetaData("selectable", $_REQUEST["queryable"] == '1' ? 'true' : 'false'); $oLayer->setprojection("+init=" . strtolower($aSRS[0])); $oMap->save($_SESSION['maps'][$mapName]); $szReturn->wms_connection = $_REQUEST["servername"]; $szReturn->wms_format = $_REQUEST["imageFormat"]; $szReturn->wms_name = $_REQUEST["layername"]; $szReturn->wms_title = $_REQUEST["owstitle"]; $szReturn->wms_version = "1.1.1"; $szReturn->wms_srs = $aSRS[0]; $szReturn->wmsservicetitle = $gwmsServiceTitle; $szReturn->addedLayer = true; } return $szReturn; }
<div id=filtroDeLetras></div> <div id="comboMapfiles" style="height:160px;">Aguarde...</div> <?php $mapfile = str_replace("\\", "/", $mapfile); $servidor = "http://" . $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . "/" . basename($locaplic) . "/admin/php/preview.php"; if (!empty($extensao)) { echo "<iframe id='mapaPreview' src='../../mashups/openlayers3.php?mapext=" . $extensao . "&servidor=" . $servidor . "&fundo=e_wsm&nocache=sim&DESLIGACACHE=sim&controles=navigation,panzoombar,scaleline,mouseposition&botoes=identifica&largura=550&altura=400&temas=" . $mapfile . "' style='position:relative;top:2px;overflow:hidden;width:100%;height:450px;border:0px solid gray;'>"; } else { echo "<iframe id='mapaPreview' src='../../mashups/openlayers3.php?servidor=" . $servidor . "&fundo=e_wsm&nocache=sim&DESLIGACACHE=sim&controles=navigation,panzoombar,scaleline,mouseposition&botoes=identifica&largura=550&altura=400&temas=" . $mapfile . "' style='position:relative;top:2px;overflow:hidden;width:100%;height:450px;border:0px solid gray;'>"; } echo "</iframe>"; echo "<input type=hidden name=tipo value=gravar />"; if (!@ms_newMapObj($mapfile)) { echo "<span style=color:red <b>Não foi possível criar o mapa. Verifique as permissões ou se há algum erro no mapfile</b></span><br><br>"; } else { $mapa = ms_newMapObj($mapfile); $n = $mapa->numlayers; echo "<br>Obs.: o corte de imagens não é considerado no preview"; echo "<br>Ajudante de cores RGB: <input type=text value='clique' size=10 id='corrgb' onclick=\"i3GEO.util.abreCor('','corrgb','rgbSep')\" />"; echo "<br><br>Colunas dos layers:<br><br>"; for ($i = 0; $i < $n; $i++) { if (@$mapa->getlayer($i)) { $l = $mapa->getlayer($i); echo $l->name . ": " . implode(",", pegaItens($l)) . "<br><br>"; } else { echo "<span style=color:red <b>Não foi possível criar o LAYER {$l->name}. Verifique as permissões ou se há algum erro no mapfile</b></span><br><br>"; } } } ?> </fieldset>
/** * @param $mapfile * @param $corx * @param $cory * @param $minx * @param $maxx * @param $miny * @param $maxy * @param $xsize * @param $ysize * @param $layers * @param $labels * @param $zoom * @param bool $changeleg * @param int $corx2 * @param int $cory2 * @return xajaxResponse */ function map_redraw($mapfile, $corx, $cory, $minx, $maxx, $miny, $maxy, $xsize, $ysize, $layers, $labels, $zoom, $changeleg = false, $corx2 = 0, $cory2 = 0) { global $prefs; $objResponse = new xajaxResponse(); if (strstr($mapfile, '..')) { $msg = tra('You do not have permission to do that'); $objResponse->alert($msg); return $objResponse; } $prefs['map_path'] = preg_replace('/\\/?$/', '/', $prefs['map_path']); //checking the mapfile if (!is_file($prefs['map_path'] . $mapfile) || preg_match('/(\\/\\.)/', $prefs['map_path'] . $mapfile)) { $msg = tra('invalid mapfile name'); $objResponse->alert($msg); return $objResponse; } $map = ms_newMapObj($prefs['map_path'] . $mapfile); for ($j = 0; $j < $map->numlayers; $j++) { $my_layer = $map->getLayer($j); if ($layers[$j] == 'true') { $my_layer->set('status', MS_ON); } else { $my_layer->set('status', MS_OFF); } if ($labels[$j] == 'false') { $my_layer->set('labelmaxscale', 0); } } $map->Set('width', $xsize); $map->Set('height', $ysize); $my_point = ms_newpointObj(); if ($zoom == 3) { $my_point->setXY($map->width / 2, $map->height / 2); } else { $my_point->setXY(floor($corx), floor($cory)); } $my_extent = ms_newrectObj(); $my_extent->setextent($minx, $miny, $maxx, $maxy); $result = ''; if ($zoom == 3) { $map->zoompoint(1, $my_point, $map->width, $map->height, $my_extent); $result = map_query($map, $corx, $cory); } elseif ($zoom == 5) { $my_rect = ms_newrectObj(); $my_rect->setextent($corx, $cory, $corx2, $cory2); $map->zoomrectangle($my_rect, $map->width, $map->height, $my_extent); $objResponse->assign('minx', 'value', $map->extent->minx); $objResponse->assign('miny', 'value', $map->extent->miny); $objResponse->assign('maxx', 'value', $map->extent->maxx); $objResponse->assign('maxy', 'value', $map->extent->maxy); $objResponse->assign('map', 'style.cursor', 'default'); $objResponse->assign('zoomselect', 'style.visibility', 'hidden'); $objResponse->script("xMoveTo(xGetElementById('map'),0,0);"); $objResponse->script('minx=' . $map->extent->minx . ';'); $objResponse->script('miny=' . $map->extent->miny . ';'); $objResponse->script('maxx=' . $map->extent->maxx . ';'); $objResponse->script('maxy=' . $map->extent->maxy . ';'); } else { $map->zoompoint(1, $my_point, $map->width, $map->height, $my_extent); $objResponse->assign('minx', 'value', $map->extent->minx); $objResponse->assign('miny', 'value', $map->extent->miny); $objResponse->assign('maxx', 'value', $map->extent->maxx); $objResponse->assign('maxy', 'value', $map->extent->maxy); $objResponse->assign('map', 'style.cursor', 'move'); $objResponse->script("xMoveTo(xGetElementById('map'),0,0);"); $objResponse->script('minx=' . $map->extent->minx . ';'); $objResponse->script('miny=' . $map->extent->miny . ';'); $objResponse->script('maxx=' . $map->extent->maxx . ';'); $objResponse->script('maxy=' . $map->extent->maxy . ';'); } $image = $map->drawquery(); $image_url = $image->saveWebImage(); if ($zoom != 3) { $image_ref = $map->drawReferenceMap(); $image_ref_url = $image_ref->saveWebImage(); $image_ref->free(); } if ($changeleg) { $image_leg = $map->drawLegend(); $image_leg_url = $image_leg->saveWebImage(); $image_leg->free(); } if ($zoom == 2 || $zoom == 5) { $image_scale = $map->drawScaleBar(); $image_scale_url = $image_scale->saveWebImage(); $image_scale->free(); } $image->free(); $objResponse->assign('innerBoxContent', 'innerHTML', $result); $objResponse->assign('resultBox', 'innerHTML', $result); $objResponse->assign('map', 'src', $image_url); if ($zoom != 3) { $objResponse->assign('ref', 'src', $image_ref_url); } if ($zoom == 2 || $zoom == 5) { $objResponse->assign('scale', 'src', $image_scale_url); } if ($changeleg) { $objResponse->assign('leg', 'src', $image_leg_url); } return $objResponse; }
<?php define(ONDEI3GEO, "../../.."); include dirname(__FILE__) . "/../../../ms_configura.php"; include_once dirname(__FILE__) . "/../../../classesphp/sani_request.php"; $id_menu = filter_var($_GET["id_menu"], FILTER_SANITIZE_NUMBER_INT); $nome_menu = filter_var($_GET["nome_menu"], FILTER_SANITIZE_STRING); $id_grupo = filter_var($_GET["id_grupo"], FILTER_SANITIZE_NUMBER_INT); $nome_grupo = filter_var($_GET["nome_grupo"], FILTER_SANITIZE_STRING); // pega a extensao geografica if ($ogcwsmap == "") { $ogcwsmap = $locaplic . "/aplicmap/ogcws.map"; } $map = ms_newMapObj($ogcwsmap); $mapext = $map->extent->minx . "," . $map->extent->miny . "," . $map->extent->maxx . "," . $map->extent->maxy; error_reporting(0); include ONDEI3GEO . "/init/head.php"; ?> <link rel='stylesheet' type='text/css' href='../../index.css'> <body style="padding-top: 55px;" id="topo"> <nav class="navbar navbar-default navbar-fixed-top"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="../../../init/index.php?home="><?php echo $mensagemInicia; ?>
echo "<div class='alert alert-danger' role='alert'>Erro IMAGEPATH vazio</div>"; } $imgo->saveImage($nome); $nome = $imgo->imageurl . basename($nome); echo "<img src={$nome} />"; echo " \n"; $error = ""; ms_ResetErrorList(); echo "<h4>Carregando o map_file geral1... e acrescentando os limites estaduais (aplicmap/estadosl...) </h4>"; if (isset($estadosl)) { $maptemp = ms_newMapObj($locaplic . "/aplicmap/" . $estadosl . ".map"); } else { if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) { $maptemp = ms_newMapObj($locaplic . "/aplicmap/estadoslwindows.map"); } else { $maptemp = ms_newMapObj($locaplic . "/aplicmap/estadosl.map"); } } while ($error && $error->code != MS_NOERR) { printf("<div class='alert alert-danger' role='alert'>Error in %s: %s<br></div>", $error->routine, $error->message); $error = $error->next(); } echo <<<HTML <h4>Se o mapa não aparecer verifique os caminhos no ms_configura.php e no estadosl.map ou estadoslwindows.map Um problema bastante comum é o não reconhecimento do diretório ms_tmp pelo Apache. O diretorio ms_tmp é utilizado pelo Mapserver e pelo i3geo para armazenar dados temporários. É nesse diretorio que ficam as imagens do mapa. Quando o Apache não consegue utilizar esse diretório, a imagem não será mostrada,
Purpose: Use this file to test mapfiles Instructions: - modify the MAPFILE path and the name of the phpmapscript MODULE (lines 16 & 17) - in a web browser goto http://127.0.0.1/quickmap.php - an image of your data should be displayed in your browser, or a MapServer error */ // define variables define("MAPFILE", "C:/ms4w/apps/gmap/htdocs/gmap75.map"); define("MODULE", "php_mapscript.dll"); // load the mapscript module if (!extension_loaded("MapScript")) { dl(MODULE); } // open map $oMap = ms_newMapObj(MAPFILE); //force all errors to display // comment out the next 2 lines, useful on servers not displaying errors //ini_set('display_errors','On'); //error_reporting(E_ALL); // set projection if necessary //$oMap->setProjection("init=epsg:42304"); // set image size $oMap->setsize(400, 300); // set image format $oMap->selectoutputformat("png"); // draw map $oImage = $oMap->draw(); // set header header("Content-type: image/gif"); // output map
$layer->setmetadata("nomeoriginal", $layer1->name); if (connection_aborted()) { exit; } $salvo = $map->save($map_file); $retorno = "ok"; } } else { $retorno = "layer {$nomeLayer} nao encontrado"; } } else { $retorno = "mapfile nao encontrado em temas"; } break; case "REMOVER": $map = ms_newMapObj($map_file); $layer = $map->getlayerbyname($tema); if ($layer != "") { $layer->set("status", MS_DELETE); $salvo = $map->save($map_file); } $retorno = "ok"; break; /* * Retorna os valores obtidos de um programa PHP incluido nos parametros do plugin * Utilizado para pegar a lista de valores que sera apresentada ao usuario */ /* * Retorna os valores obtidos de um programa PHP incluido nos parametros do plugin * Utilizado para pegar a lista de valores que sera apresentada ao usuario */
session_id($g_sid); session_start(); if (!empty($_SESSION["map_file"])) { $mapateste = ms_newMapObj($_SESSION["map_file"]); if ($mapateste->getlayerbyname($layer) != "") { $map_file = $_SESSION["map_file"]; } } } $map_file = heatmapMapfile(); //no caso do SAIKU, o nome do mapfile pode estar na sessao if ($map_file == "") { session_name("i3GeoPHP"); session_start(); if (!empty($_SESSION["map_file"])) { $mapateste = ms_newMapObj($_SESSION["map_file"]); if ($mapateste->getlayerbyname($layer) != "") { $map_file = $_SESSION["map_file"]; } } } $resultado = heatmapDados($map_file); $gradiente = heatmapGradiente($map_file, $layer, $tipoGradiente); if (isset($map_file) && isset($postgis_mapa) && $map_file != "") { restauraCon($map_file, $postgis_mapa); } echo $nomevariavel . ' = [' . implode(",", $resultado) . '];'; echo $nomevariavelConfig . ' = ' . $gradiente . ';'; if ($carregajs === "sim") { include_once $dir . "/../../pacotes/heatmap/src/heatmap.js"; include_once $dir . "/../../pacotes/heatmap/src/heatmap-openlayers.js";
} $varDef = array("tmpf" => "Temperatures", "tsf0" => "Pavement Temp #1", "tsf1" => "Pavement Temp #2", "tsf2" => "Pavement Temp #3", "tsf3" => "Pavement Temp #4", "dwpf" => "Dew Points", "vsby" => "Visibility", "sknt" => "Wind [knots]", "alti" => "Altimeter", "pres" => "Pressure", "barb" => "Wind Barbs", "max_tmpf" => "Maximum Temperature", "max_dwpf" => "Maximum Dew Point", "min_tmpf" => "Minimum Temperature", "gust" => "Peak Wind Gust [knots]", "relh" => "Relative Humidity", "phour" => "Hourly Rainfall", "pday" => "Today Rainfall", "pmonth" => "Rainfall This Month", "snow" => "Today Snowfall", "snowd" => "Today Snow Depth", "snoww" => "Snow Water Equivalent", "max_sknt" => "Peak Gust Today [knots]", "max_gust" => "Peak Gust Today [knots]", "feel" => "Feels Like"); $rnd = array("alti" => 2, "phour" => 2, "vsby" => 1, "tmpf" => 0, "dwpf" => 0, "pday" => 2, "pmonth" => 2, "pres" => 2, "snoww" => 2); $lats = array(); $lons = array(); $height = 350; $width = 450; foreach ($sts as $key => $value) { $lats[$key] = $sts[$key]->db["y"]; $lons[$key] = $sts[$key]->db["x"]; } $lat0 = min($lats); $lat1 = max($lats); $lon0 = min($lons); $lon1 = max($lons); $map = ms_newMapObj("../../../../data/gis/base4326.map"); $pad = 0.6; $lpad = 0.6; //$map->setextent(-83760, -2587, 478797, 433934); $map->setextent($lon0 - $lpad, $lat0 - $pad, $lon1 + $lpad, $lat1 + $pad); $namer = $map->getlayerbyname("namerica"); $namer->set("status", 1); $lakes = $map->getlayerbyname("lakes"); $lakes->set("status", 1); $GOESBASE = "/home/ldm/data/gis/images/4326/goes"; $goes_east1V = $map->getlayerbyname("goes_east1V"); $goes_east1V->set("data", "{$GOESBASE}/east1V_0.tif"); $goes_east1V->set("status", in_array("goes_east1V", $layers)); $goes_west1V = $map->getlayerbyname("goes_west1V"); $goes_west1V->set("data", "{$GOESBASE}/west1V_0.tif"); $goes_west1V->set("status", in_array("goes_west1V", $layers));
function pegaSelecaoRegioes() { global $m, $map_file, $postgis_mapa; $codigo_tipo_regiao = ""; $selecaoRegiao = array(); $regiao = ""; $item = ""; $registros = ""; if ($map_file != "") { $mapa = ms_newMapObj($map_file); $c = $mapa->numlayers; for ($i = 0; $i < $c; ++$i) { $l = $mapa->getlayer($i); //verifica o alias na conexao if (!empty($postgis_mapa)) { if ($l->connectiontype == MS_POSTGIS) { $lcon = $l->connection; if ($lcon == " " || $lcon == "" || in_array($lcon, array_keys($postgis_mapa))) { if ($lcon == " " || $lcon == "") { $l->set("connection", $postgis_mapa); } else { $l->set("connection", $postgis_mapa[$lcon]); } } } } // $registros = array(); if ($l->status == MS_DEFAULT && $l->getmetadata("METAESTAT_CODIGO_TIPO_REGIAO") != "") { //verifica se tem selecao $qyfile = dirname($map_file) . "/" . $l->name . ".php"; if (file_exists($qyfile)) { $codigo_tipo_regiao = $l->getmetadata("METAESTAT_CODIGO_TIPO_REGIAO"); //pega os registros $shapes = retornaShapesSelecionados($l, $map_file, $mapa); //pega o nome da coluna que identifica cada registro $regiao = $m->listaTipoRegiao($codigo_tipo_regiao); $item = $regiao["identificador"]; foreach ($shapes as $shape) { $registros[] = $shape->values[$item]; } $reg = $item . " IN ('" . implode("','", $registros) . "') "; $selecaoRegiao[$codigo_tipo_regiao] = array("item" => $item, "sql" => $reg); break; //mantem a primeira ocorrencia de regiao que possui selecao } else { $selecaoRegiao[$codigo_tipo_regiao] = ""; } } } return array("selecaoRegiao" => $selecaoRegiao, "codigo_tipo_regiao" => $codigo_tipo_regiao); } }
function ligaDesligaTemas($ligar, $desligar, $adicionar = "nao") { if (strTolower($adicionar) == "sim") { $teste = explode(",", $ligar); $adicionar = array(); $verificar = array(); foreach ($this->layers as $layerE) { $verificar[] = $layerE->getmetadata("nomeoriginal"); $verificar[] = $layerE->name; } foreach ($teste as $t) { if (!in_array($t, $verificar)) { $adicionar[] = $t; } } if (count($adicionar > 0)) { $this->adicionaTema(implode(",", $adicionar), $this->locaplic, $random = "sim"); $this->salva(); $this->mapa = ms_newMapObj($this->arquivo); $c = $this->mapa->numlayers; for ($i = 0; $i < $c; ++$i) { $this->layers[] = $this->mapa->getlayer($i); } } } if ($desligar == "todos") { $desligar = $this->mapa->getalllayernames(); $desligar = implode(",", $desligar); } if ($ligar != "") { $listal = explode(",", $ligar); foreach ($listal as $layer) { $ls = array(); $vermultilayer = new vermultilayer(); $vermultilayer->verifica($this->arquivo, $layer); if ($vermultilayer->resultado == 1) { $ls = $vermultilayer->temas; } $ls[] = $layer; foreach ($ls as $l) { $l = $this->mapa->getlayerbyname($l); if ($l) { $l->set("status", 2); } } } } if ($desligar != "") { $listad = explode(",", $desligar); foreach ($listad as $layer) { $ls = array(); $vermultilayer = new vermultilayer(); $vermultilayer->verifica($this->arquivo, $layer); if ($vermultilayer->resultado == 1) { $ls = $vermultilayer->temas; } else { $ls[] = $layer; } foreach ($ls as $l) { $l = $this->mapa->getlayerbyname($l); if ($l) { $l->set("status", 0); } } } } return "ok"; }
removeCabecalho($arq); } } $retorno = "ok"; break; case "INCLUI": restauraCon($map_file, $postgis_mapa); $mapa = ms_newMapObj($map_file); $l = $mapa->getlayerbyname($tema); if ($l != "") { $l->setmetadata("storymap", $storymap); $mapa->save($map_file); } $arq = $locaplic . "/temas/" . $tema . ".map"; if (file_exists($arq)) { $mapa = ms_newMapObj($arq); $l = $mapa->getlayerbyname($tema); if ($l != "") { $l->setmetadata("storymap", str_replace("\\", "'", $_POST["storymap"])); $mapa->save($arq); removeCabecalho($arq); } } $retorno = "ok"; break; } cpjson($retorno); //TODO colocar essa funcao em algum lugar que permita reaproveitamento function removeCabecalho($arq, $symbolset = true) { $handle = fopen($arq, "r");
function salvaMapfile() { global $locaplic, $dbhw, $codigo, $gravarTexto, $esquemaadmin; if (empty($gravarTexto)) { return; } $mapfile = $locaplic . "/temas/" . $codigo . ".map"; $original = file_get_contents($mapfile); $fp = fopen($mapfile, "w"); if ($fp == false) { echo "<span style=color:red <b>Não foi possível salvar o arquivo. Verifique as permissões ou se há algum erro no mapfile</b></span><br><br>"; exit; } else { // remove itens vazios $novoTexto = array(); $testar = array("TEMPORIZADOR", "PALLETESTEP", "LTEMPOITEMIMAGEM", "METAESTAT_ID_MEDIDA_VARIAVEL", "GMOPACITY", "GMSTATUS", "ICONETEMA", "LTEMPOITEMTITULO", "DESCRIPTION_TEMPLATE", "LTEMPOITEMLINK", "TILES", "METAESTAT_CODIGO_TIPO_REGIAO", "ARQUIVOTEMAORIGINAL", "PALLETEFILE", "NOMEORIGINAL", "OLSTATUS", "PERMITEDOWNLOAD", "LTEMPOFORMATODATA", "FILTROORIGINAL", "PERMITECOMENTARIO", "LTEMPOITEMICONE", "DATAORIGINAL", "PLUGINI3GEO", "METAESTAT", "ITEMBUSCARAPIDA", "ARQUIVODOWNLOAD", "ARQUIVOKMZ", "PERMITEKML", "PERMITEOGC", "CONVCARACTER", "CORTEPIXELS", "EDITORSQL", "LTEMPOCONVENCODE", "LTEMPOITEMFIM", "OLOPACITY", "LEGENDAWMS", "LEGENDAIMG", "KEYIMAGE", "TILEINDEX", "TILEITEM", "SYMBOL", "LABELITEM", "FILTERITEM", "GROUP", "ENCODING", "TIP", "CLASSE", "ITENSDESC", "CLASSESNOME", "ITENSLINK", "ESCALA", "CLASSESSIMBOLO", "MENSAGEM", "EXTENSAO", "CLASSESITEM", "ESCONDIDO", "CLASSESCOR", "DOWNLOAD", "CLASSESTAMANHO", "ITENS", "TEMA", "APLICAEXTENSAO", "IDENTIFICA", "TRANSITIONEFFECT"); foreach (preg_split('~[\\r\\n]+~', $gravarTexto) as $line) { $teste = strtoupper($line); $teste = trim($teste); $teste = str_replace(array(" ", "'", '"'), "", $teste); $teste = preg_replace('/[\\n\\r\\t ]*/', '', $teste); $passou = true; foreach ($testar as $t) { if ($teste == $t) { $passou = false; } } if ($passou == true) { if (mb_detect_encoding($line, 'UTF-8') == "UTF-8") { $line = mb_convert_encoding($line, "ISO-8859-1", "UTF-8"); } $novoTexto[] = $line; } } fwrite($fp, implode("\r\n", $novoTexto)); } fclose($fp); // testa o mapfile ms_ResetErrorList(); if (!@ms_newMapObj($mapfile)) { echo "Erro no arquivo sera mantido o original<br>"; $error = ms_GetErrorObj(); while ($error && $error->code != MS_NOERR) { printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message); $error = $error->next(); } $fp = fopen($mapfile, "w"); fwrite($fp, $original); fclose($fp); exit; } // verifica os metadata que sao armazenados tambem no banco de dados de administracao // isso e necessario para manter a consistencia caso o usuario altere manualmente os valores // cria o objeto map $mapa = ms_newMapObj($mapfile); $layer = $mapa->getlayerbyname($codigo); if ($layer == "") { return "<br><span style='color:red;'>Atenção: não existe nenhum LAYER com NAME igual a " . $codigo . "</span><br>"; } else { // pega o metadata $meta = $layer->getmetadata("permitedownload"); $meta = strtoupper($meta); $dataCol = array(); if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) { $dataCol["download_tema"] = $meta; } $meta = $layer->getmetadata("permiteogc"); $meta = strtoupper($meta); if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) { $dataCol["ogc_tema"] = $meta; } $meta = $layer->getmetadata("permitekml"); $meta = strtoupper($meta); if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) { $dataCol["kml_tema"] = $meta; } $meta = $layer->getmetadata("permitekmz"); $meta = strtoupper($meta); if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) { $dataCol["kmz_tema"] = $meta; } $resultado = i3GeoAdminUpdate($dbhw, "i3geoadmin_temas", $dataCol, "WHERE codigo_tema = '{$codigo}'"); } }
// //verifica se existe o tema em i3geo/temas // $arqoriginal = ""; if (file_exists($locaplic . "/temas/" . $layert->name . ".map")) { $nomeoriginal = $layert->name; $arqoriginal = $locaplic . "/temas/" . $layert->name . ".map"; } elseif (file_exists($locaplic . "/temas/" . $layert->getmetadata("nomeoriginal") . ".map")) { $nomeoriginal = $layert->getmetadata("nomeoriginal"); $arqoriginal = $locaplic . "/temas/" . $layert->getmetadata("nomeoriginal") . ".map"; } if ($arqoriginal != "") { // //o tema existe // $mapo = ms_newMapObj($arqoriginal); $layero = $mapo->getlayerbyname($nomeoriginal); $layero->setmetadata("cache", "nao"); // //remove as classes do layer original // $nclasses = $layero->numclasses; if ($nclasses > 0) { for ($j = 0; $j < $nclasses; ++$j) { $classe = $layero->getClass($j); $classe->set("status", MS_DELETE); } } // //copia as classes do layer do upload para o original //