From e4f491cc9e13844ff2db02cebf8c54e9700ec107 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Thu, 18 Oct 2018 15:25:14 -0300 Subject: [PATCH] Correções nas ferramentas filtro e renderização de elementos selecionados --- classesphp/classe_selecao.php | 2 ++ classesphp/funcoes_gerais.php | 1 + classesphp/mapa_googlemaps.php | 106 +++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------- classesphp/mapa_openlayers.php | 5 +++-- ferramentas/identifica/index.js | 64 +++++++++++++++++++++++++++++++++++++++++++--------------------- ms_configura.php | 2 +- temas/regioesdesaude.map | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 195 insertions(+), 89 deletions(-) create mode 100644 temas/regioesdesaude.map diff --git a/classesphp/classe_selecao.php b/classesphp/classe_selecao.php index 593caf3..a250123 100755 --- a/classesphp/classe_selecao.php +++ b/classesphp/classe_selecao.php @@ -117,6 +117,7 @@ $ext - extensão geográfica do mapa $this->arquivo = str_replace(".map","",$map_file).".map"; if($tema != "" && @$this->mapa->getlayerbyname($tema)) $this->layer = $this->mapa->getlayerbyname($tema); + $this->nome = $tema; $c = $this->mapa->numlayers; for ($i=0;$i < $c;++$i) @@ -882,6 +883,7 @@ $retornaShapes - retorna os shapes selecionados. Nesse caso, nao e gerado o arqu $this->selecaoLimpa(); $tipo = "adiciona"; } + if(!$this->layer){ return "erro"; } diff --git a/classesphp/funcoes_gerais.php b/classesphp/funcoes_gerais.php index 51033aa..793d22c 100755 --- a/classesphp/funcoes_gerais.php +++ b/classesphp/funcoes_gerais.php @@ -554,6 +554,7 @@ function listaTrueType() function substituiCon($map_file, $postgis_mapa) { // error_reporting(0); + return; if (! empty($postgis_mapa) && (file_exists($map_file))) { if (! @ms_newMapObj($map_file)) { return false; diff --git a/classesphp/mapa_googlemaps.php b/classesphp/mapa_googlemaps.php index 9d6a22f..8ccd241 100755 --- a/classesphp/mapa_googlemaps.php +++ b/classesphp/mapa_googlemaps.php @@ -55,8 +55,6 @@ * i3geo/classesphp/mapa_googlemaps.php * */ -// error_reporting(0); -// error_reporting(0); include ("sani_request.php"); // para efeitos de compatibilidade if (! function_exists('ms_GetVersion')) { @@ -96,6 +94,9 @@ $postgis_mapa = $_SESSION["postgis_mapa"]; $cachedir = $_SESSION["cachedir"]; $i3georendermode = $_SESSION["i3georendermode"]; +$projInObj = ms_newprojectionobj("proj=latlong,a=6378137,b=6378137"); +$projOutObj = ms_newprojectionobj("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m"); + if (! empty($_GET["request"])) { $_GET["REQUEST"] = $_GET["request"]; } @@ -127,9 +128,6 @@ if ($_GET["REQUEST"] == "GetFeatureInfo" || strtolower($_GET["REQUEST"]) == "get $x --; $y --; - $projInObj = ms_newprojectionobj("proj=latlong,a=6378137,b=6378137"); - $projOutObj = ms_newprojectionobj("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m"); - $poPoint1 = ms_newpointobj(); $poPoint1->setXY($lon1, $lat1); $poPoint1->project($projInObj, $projOutObj); @@ -309,6 +307,7 @@ $legenda = $mapa->legend; $legenda->set("status", MS_OFF); $escala = $mapa->scalebar; $escala->set("status", MS_OFF); + if (trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") { $o->setOption("QUANTIZE_FORCE", "OFF"); } @@ -331,11 +330,13 @@ if ($cortePixels > 0) { if ($qy != true) { $img = $mapa->draw(); } else { - $handle = fopen($qyfile, "r"); - $conteudo = fread($handle, filesize($qyfile)); - fclose($handle); + //$handle = fopen($qyfile, "r"); + //$conteudo = fread($handle, filesize($qyfile)); + //fclose($handle); + $conteudo = file_get_contents($qyfile); $shp = unserialize($conteudo); $l = $mapa->getLayerByname($_GET["layer"]); + $c = $mapa->querymap->color; $indxlayer = $l->index; if ($l->connectiontype != MS_POSTGIS) { if($l->type == MS_LAYER_POINT){ @@ -354,15 +355,14 @@ if ($qy != true) { } } foreach ($shp as $indx) { - $mapa->querybyindex($indxlayer, - 1, $indx, MS_TRUE); + $mapa->querybyindex($indxlayer, -1, $indx, MS_TRUE); } $qm = $mapa->querymap; - $qm->set("width", $_GET["WIDTH"]); - $qm->set("height", $_GET["HEIGHT"]); + $qm->set("width", 256); + $qm->set("height", 256); $img = $mapa->drawQuery(); } else { $img = $mapa->draw(); - $c = $mapa->querymap->color; $numclasses = $l->numclasses; if ($numclasses > 0) { $classe0 = $l->getClass(0); @@ -378,37 +378,25 @@ if ($qy != true) { } $cor = $classe0->getstyle(0)->color; $cor->setrgb($c->red, $c->green, $c->blue); - $cor = $classe0->getstyle(0)->outlinecolor; - $cor->setrgb($c->red, $c->green, $c->blue); - // $v = versaoMS(); - if ($versao["principal"] == 6) { - $l->open(); - foreach ($shp as $indx) { - $shape = $l->getShape(new resultObj($indx)); + $status = $l->open(); + $rect = $mapa->extent; + $rect->project($projOutObj,$projInObj); + $status = $l->whichShapes($rect); + while ($shape = $l->nextShape()) { + //$shape->project($projInObj,$projOutObj); + if (in_array($shape->index, $shp)){ + $shape->project($projInObj,$projOutObj); + //echo $shape->toWkt();exit; + //$shape = ms_shapeObjFromWkt($shape->toWkt()); $shape->draw($mapa, $l, $img); } - $l->close(); - } else { - $l->open(); - foreach ($shp as $indx) { - $shape = $l->getfeature($indx, - 1); - $shape->draw($mapa, $l, $img); - } - $l->close(); } + $l->close(); } + $cache = false; } -if (! function_exists('imagepng')) { - $s = PHP_SHLIB_SUFFIX; - @dl('php_gd.' . $s); - if (! function_exists('imagepng')) { - @dl('php_gd2.' . $s); - } - if (! function_exists('imagepng')) { - $_GET["TIPOIMAGEM"] = ""; - } -} -if (trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") { +//exit; +if ($_GET["TIPOIMAGEM"] != "" && $_GET["TIPOIMAGEM"] != "nenhum") { if ($img->imagepath == "") { echo "Erro IMAGEPATH vazio"; exit(); @@ -427,34 +415,23 @@ if (trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") { imagesavealpha($img, true); cabecalhoImagem($nomer); imagepng($img); + //imagedestroy($img); } else { - if ($cache == true) { - $nomer = salvaCacheImagem(); + if ($cache == true && $_GET["cache"] != "nao") { + // cache ativo. Salva a imagem em cache + $nomer = salvaCacheImagem($cachedir, $map_fileX, $_GET["tms"]); cabecalhoImagem($nomer); - carregaCacheImagem(); + if ($_SESSION["i3georendermode"] == 2) { + header("X-Sendfile: $nomer"); + } else { + readfile($nomer); + } } else { - if ($_SESSION["i3georendermode"] == 0 || ($_SESSION["i3georendermode"] == 1 && $cortePixels > 0)) { - $nomer = ($img->imagepath) . "temp" . nomeRand() . ".png"; - if ($img->imagepath == "") { - ilegal(); - } - $img->saveImage($nomer); - // - // corta a imagem gerada para voltar ao tamanho normal - // - if ($cortePixels > 0) { - $img = cortaImagemDisco($nomer, $cortePixels, 256); - } else { - $img = imagecreatefrompng($nomer); - imagealphablending($img, false); - imagesavealpha($img, true); - } - cabecalhoImagem($nomer); - imagepng($img); - imagedestroy($img); - exit(); + // cache inativo + if ($img->imagepath == "") { + ilegal(); } - if ($_SESSION["i3georendermode"] == 1) { + if ($_SESSION["i3georendermode"] == 0 || ($_SESSION["i3georendermode"] == 1 && $cortePixels > 0)) { ob_clean(); header('Content-Type: image/png'); $img->saveImage(); @@ -466,13 +443,12 @@ if (trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") { // corta a imagem gerada para voltar ao tamanho normal // if ($cortePixels > 0) { - $img = cortaImagemDisco($nomer, $cortePixels, 256); + $img = cortaImagemDisco($nomer, $cortePixels, $_GET["WIDTH"]); } cabecalhoImagem($nomer); - header("X-Sendfile: $nomer"); + header("X-Sendfile: ".$nomer); } } - exit(); } function cabecalhoImagem($nome,$tipo="image/png") diff --git a/classesphp/mapa_openlayers.php b/classesphp/mapa_openlayers.php index 233fb73..e846abe 100755 --- a/classesphp/mapa_openlayers.php +++ b/classesphp/mapa_openlayers.php @@ -318,6 +318,9 @@ if ($cache == true && $_GET["cache"] != "nao") { if (isset($_GET["map_size"])) { $map_size = explode(" ", $_GET["map_size"]); $mapa->setsize($map_size[0], $map_size[1]); +} else { + $map_size = array(256,256); + $mapa->setsize($map_size[0], $map_size[1]); } if (isset($_GET["mapext"])) { @@ -418,7 +421,6 @@ if ($qy != true) { $img = $mapa->drawQuery(); } else { $img = $mapa->draw(); - $numclasses = $l->numclasses; if ($numclasses > 0) { $classe0 = $l->getClass(0); @@ -476,7 +478,6 @@ if ($_GET["TIPOIMAGEM"] != "" && $_GET["TIPOIMAGEM"] != "nenhum") { readfile($nomer); } } else { - // cache inativo if ($img->imagepath == "") { ilegal(); diff --git a/ferramentas/identifica/index.js b/ferramentas/identifica/index.js index b990609..282260c 100755 --- a/ferramentas/identifica/index.js +++ b/ferramentas/identifica/index.js @@ -452,30 +452,52 @@ i3GEOF.identifica = { }, filtrar : function(tema, item, valor) { i3GEO.janela.abreAguarde(); - var filtro = "", - temp = function(retorno) { - i3GEO.janela.fechaAguarde(); - i3GEO.Interface.atualizaTema(retorno, tema); - }, - p = i3GEO.configura.locaplic + "/ferramentas/filtro/exec.php?base64=sim&g_sid=" + i3GEO.configura.sid + "&funcao=inserefiltro", - cp = new cpaint(); - - filtro = "(*[" + item + "]* = *" + valor + "*)"; - cp.set_response_type("JSON"); - cp.set_transfer_mode('POST'); - cp.call(p, "insereFiltro", temp, "tema=" + tema + "&filtro=" + i3GEO.util.base64encode(filtro)); + $.get( + i3GEO.configura.locaplic+"/ferramentas/filtro/exec.php", + { + g_sid: i3GEO.configura.sid, + base64: "sim", + funcao: "inserefiltro", + tema: tema, + filtro: i3GEO.util.base64encode("(*[" + item + "]* = *" + valor + "*)") + } + ) + .done( + function(data, status){ + i3GEO.janela.fechaAguarde(); + i3GEO.Interface.atualizaTema(data, tema); + } + ) + .fail( + function(data){ + i3GEO.janela.fechaAguarde(); + i3GEO.janela.snackBar({content: data.statusText, style:'red'}); + } + ); }, removeFiltro : function(tema) { i3GEO.janela.abreAguarde(); - var temp = function(retorno) { - i3GEO.janela.fechaAguarde(); - i3GEO.Interface.atualizaTema(retorno, tema); - }, p = - i3GEO.configura.locaplic + "/ferramentas/filtro/exec.php?base64=nao&g_sid=" + i3GEO.configura.sid + "&funcao=inserefiltro", cp = - new cpaint(); - cp.set_response_type("JSON"); - cp.set_transfer_mode('POST'); - cp.call(p, "insereFiltro", temp, "tema=" + tema + "&filtro="); + $.get( + i3GEO.configura.locaplic+"/ferramentas/filtro/exec.php", + { + g_sid: i3GEO.configura.sid, + funcao: "inserefiltro", + tema: tema, + filtro: "" + } + ) + .done( + function(data, status){ + i3GEO.janela.fechaAguarde(); + i3GEO.Interface.atualizaTema(data, tema); + } + ) + .fail( + function(data){ + i3GEO.janela.fechaAguarde(); + i3GEO.janela.snackBar({content: data.statusText, style:'red'}); + } + ); }, adicionaPontoRegiao : function(idjanela) { var p = i3GEO.configura.locaplic + "/ferramentas/editortema/exec.php?funcao=adicionaGeometria&g_sid=" + i3GEO.configura.sid, tema = diff --git a/ms_configura.php b/ms_configura.php index e6e3ae3..d92a37f 100755 --- a/ms_configura.php +++ b/ms_configura.php @@ -886,5 +886,5 @@ if(empty($_COOKIE["i3geolingua"]) && array_key_exists('HTTP_ACCEPT_LANGUAGE',$_S } setcookie('i3geolingua', $l, time()+60*60*24*365, '/'); } -error_reporting(E_ALL); +error_reporting(0); ?> diff --git a/temas/regioesdesaude.map b/temas/regioesdesaude.map new file mode 100644 index 0000000..3cde300 --- /dev/null +++ b/temas/regioesdesaude.map @@ -0,0 +1,104 @@ +MAP + FONTSET "../symbols/fontes.txt" + SYMBOLSET "../symbols/simbolosv6.sym" + LAYER + COMPOSITE + OPACITY 40 + END # COMPOSITE + CONNECTION "" + CONNECTIONTYPE POSTGIS + DATA "geom FROM (select class_regiao,class_regiao_desc,geom FROM dbauxiliares.tb_class_regiao WHERE superintendencia = 't') as foo USING UNIQUE class_regiao USING SRID=4674" + METADATA + "cache" "sim" + "TIP" "class_regiao,class_regiao_desc" + "CLASSE" "SIM" + "permitekmz" "SIM" + "ITENSDESC" "Codigo,Nome" + "TILES" "SIM" + "ITENSLINK" "," + "extensao" "-48.285791068245 -16.050264262644 -47.308386987058 -15.500255153363" + "permitedownload" "SIM" + "download" "SIM" + "UTFDATA" "class_regiao_desc" + "ITENS" "class_regiao,class_regiao_desc" + "permitekml" "SIM" + "permiteogc" "SIM" + "convcaracter" "SIM" + "TEMA" "Regiões de saúde (superintendências)" + "IDENTIFICA" "sim" + END # METADATA + NAME "regioesdesaude" + PROCESSING "LABEL_NO_CLIP=True" + PROCESSING "POLYLINE_NO_CLIP=True" + STATUS DEFAULT + TEMPLATE "none.htm" + TILEITEM "location" + TYPE POLYGON + UNITS METERS + CLASS + NAME "Região Central" + EXPRESSION ('[class_regiao]'eq'2') + STYLE + COLOR 203 115 203 + OUTLINECOLOR 255 255 255 + END # STYLE + TITLE "" + END # CLASS + CLASS + NAME "Região Oeste" + EXPRESSION ('[class_regiao]'eq'5') + STYLE + COLOR 17 166 64 + OUTLINECOLOR 255 255 255 + END # STYLE + TITLE "" + END # CLASS + CLASS + NAME "Região Norte" + EXPRESSION ('[class_regiao]'eq'6') + STYLE + COLOR 2 210 239 + OUTLINECOLOR 255 255 255 + END # STYLE + TITLE "" + END # CLASS + CLASS + NAME "Região Sul" + EXPRESSION ('[class_regiao]'eq'3') + STYLE + COLOR 249 110 138 + OUTLINECOLOR 255 255 255 + END # STYLE + TITLE "" + END # CLASS + CLASS + NAME "Região Leste" + EXPRESSION ('[class_regiao]'eq'7') + STYLE + COLOR 243 26 74 + OUTLINECOLOR 255 255 255 + END # STYLE + TITLE "" + END # CLASS + CLASS + NAME "Região Sudoeste" + EXPRESSION ('[class_regiao]'eq'4') + STYLE + COLOR 122 60 248 + OUTLINECOLOR 255 255 255 + END # STYLE + TITLE "" + END # CLASS + CLASS + NAME "Região Centro-Sul" + EXPRESSION ('[class_regiao]'eq'1') + STYLE + COLOR 189 247 118 + OUTLINECOLOR 255 255 255 + END # STYLE + TITLE "" + END # CLASS + END # LAYER + +END # MAP + -- libgit2 0.21.2