From 54c560d6a4ba18ede2193fe51d62ff76616804e4 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Mon, 29 Mar 2010 19:31:41 +0000 Subject: [PATCH] reformulação dos códigos para uso da extensão .qy nos arquivos de seleção ao invés de .mapqy. Isso foi necessário por questões de compatibilidade entre versões do Mapserver. --- classesphp/classe_analise.php | 79 +++++++++++++++++++++++++++++++++++++++++++------------------------------------ classesphp/classe_atributos.php | 19 +++++++++++++------ classesphp/classe_mapa.php | 39 +++++++++++++++++++++++---------------- classesphp/classe_selecao.php | 61 ++++++++++++++++++++++++++++++++++--------------------------- classesphp/classe_temas.php | 25 ++++++++++++++++--------- classesphp/funcoes_gerais.php | 5 +++-- classesphp/graficos.php | 5 +++-- classesphp/mapa_controle.php | 24 ++++++++++++------------ classesphp/mapa_inicia.php | 4 +++- 9 files changed, 150 insertions(+), 111 deletions(-) diff --git a/classesphp/classe_analise.php b/classesphp/classe_analise.php index 3e22b17..cd1691e 100644 --- a/classesphp/classe_analise.php +++ b/classesphp/classe_analise.php @@ -67,6 +67,12 @@ class Analise Diretório do arquivo map_file */ protected $diretorio; + /* + Variavel: $qyfile + + Nome do arquivo de seleção (.qy) + */ + public $qyfile; /* Function: __construct @@ -81,6 +87,7 @@ $tema - Nome do tema que será processado function __construct($map_file,$tema="",$locaplic="") { //error_reporting(E_ALL); + $this->qyfile = str_replace(".map",".qy",$map_file); if(file_exists($locaplic."/funcoes_gerais.php")) include_once($locaplic."/funcoes_gerais.php"); else @@ -165,8 +172,8 @@ Include: $this->mapaDeldir($nomearq,$dir_tmp,$R_path,$locaplic); $this->deldirDir2shp($nomearq."dirsgs",$dir_tmp,$locaplic); $this->deldirDel2shp($nomearq."delsgs",$dir_tmp,$locaplic); - if(file_exists(($this->arquivo)."qy")) - {unlink(($this->arquivo)."qy");} + if(file_exists($this->qyfile)) + {unlink($this->qyfile);} return "ok"; break; case "kernel": @@ -240,8 +247,8 @@ Include: } else {return("erro");} - if(file_exists(($this->arquivo)."qy")) - {unlink(($this->arquivo)."qy");} + if(file_exists($this->qyfile)) + {unlink($this->qyfile);} return("ok"); } /* @@ -947,8 +954,8 @@ $locaplic - Localização do I3geo. //pega os shapes selecionados $itemspt = pegaItens($layerPt); $existesel = "nao"; - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} if ($layerPt->getNumresults() > 0){$existesel = "sim";} if ($existesel == "nao") { @@ -1057,8 +1064,8 @@ $locaplic - Localização do I3geo. $novolayer->setmetadata("ITENS"," "); $novolayer->setmetadata("ITENSDESC"," "); $novolayer->set("connectiontype",MS_SHAPEFILE); - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} return(implode(" ",$nomesitens)); } /* @@ -1094,8 +1101,8 @@ function distanciaptpt($temaorigem,$temadestino,$temaoverlay,$locaplic,$itemorig //define o nome do novo shapefile que será criado $nomefinal = nomeRandomico(); $nomeshp = $this->diretorio."/".$nomefinal; - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} else {return "errox";} $layerorigem = $this->mapa->getlayerbyname($temaorigem); @@ -1183,8 +1190,8 @@ function distanciaptpt($temaorigem,$temadestino,$temaoverlay,$locaplic,$itemorig $cor = $estilo->color; $cor->setrgb(255,210,0); //limpa selecao - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} return($nomeshp.".shp"); } /* @@ -1218,8 +1225,8 @@ nome do layer criado com o buffer. $nomebuffer = nomeRandomico(); $nomeshp = $this->diretorio."/".$nomebuffer; //pega os shapes selecionados - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $sopen = $this->layer->open(); if($sopen == MS_FAILURE){return "erro";} $items = pegaItens($this->layer); @@ -1330,8 +1337,8 @@ $locaplic - Localização do I3geo. $nomeCentroides = nomeRandomico(); $nomeshp = $this->diretorio."/".$nomeCentroides; //pega os shapes selecionados - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $sopen = $this->layer->open(); if($sopen == MS_FAILURE){return "erro";} $items = pegaItens($this->layer); @@ -1389,8 +1396,8 @@ $locaplic - Localização do I3geo. $novolayer->set("template","none.htm"); $novolayer->setmetadata("TEMALOCAL","SIM"); //limpa selecao - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} return("ok"); } /* @@ -1503,8 +1510,8 @@ $npty - Número de pontos em Y (opcional) $novolayer->set("data",$nomeshp.".shp"); $novolayer->setmetadata("DOWNLOAD","SIM"); $novolayer->setmetadata("TEMALOCAL","SIM"); - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} return("ok"); } /* @@ -1646,8 +1653,8 @@ $npty - Número de pontos em Y (opcional) $novolayer->setmetadata("DOWNLOAD","SIM"); $novolayer->setmetadata("TEMALOCAL","SIM"); $novolayer->set("opacity","50"); - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} return("ok"); } /* @@ -1799,8 +1806,8 @@ $npty - Número de pontos em Y (opcional) $novolayer->setmetadata("DOWNLOAD","SIM"); $novolayer->setmetadata("TEMALOCAL","SIM"); $novolayer->set("opacity","50"); - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} return("ok"); } /* @@ -1868,8 +1875,8 @@ $locaplic - Localização do I3geo $novolayer->setmetadata("DOWNLOAD","SIM"); $novolayer->setmetadata("TEMALOCAL","SIM"); $novolayer->set("opacity","80"); - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} return("ok"); } /* @@ -1890,8 +1897,8 @@ Salva o mapa acrescentando um novo layer com o resultado. else include_once "../pacotes/phpxbase/api_conversion.php"; //define o nome do novo shapefile que será criado - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $sopen = $this->layer->open(); if($sopen == MS_FAILURE){return "erro";} $res_count = $this->layer->getNumresults(); @@ -1982,8 +1989,8 @@ Salva o mapa acrescentando um novo layer com o resultado. $novolayer->set("data",$nomeshp.".shp"); $novolayer->setmetadata("DOWNLOAD","SIM"); $novolayer->setmetadata("TEMALOCAL","SIM"); - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} return("ok"); } @@ -2010,8 +2017,8 @@ $locaplic - Localização do I3geo else include_once "../pacotes/phpxbase/api_conversion.php"; //define o nome do novo shapefile que será criado - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $sopen = $this->layer->open(); if($sopen == MS_FAILURE){return "erro";} $res_count = $this->layer->getNumresults(); @@ -2091,8 +2098,8 @@ $locaplic - Localização do I3geo $novolayer->set("data",$nomeshp.".shp"); $novolayer->setmetadata("DOWNLOAD","SIM"); $novolayer->setmetadata("TEMALOCAL","SIM"); - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} return("ok"); } @@ -2405,8 +2412,8 @@ function gravaCoordenadasPt($tema,$limitepontos="TRUE",$extendelimite) $nomearq = $this->diretorio."/".$nomefinal; $itemspt = pegaItens($layerPt); $existesel = "nao"; - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} if ($layerPt->getNumresults() > 0){$existesel = "sim";} if ($existesel == "nao") {$layerPt->queryByrect($this->mapa->extent);} diff --git a/classesphp/classe_atributos.php b/classesphp/classe_atributos.php index 8caa320..9cae67a 100644 --- a/classesphp/classe_atributos.php +++ b/classesphp/classe_atributos.php @@ -63,6 +63,12 @@ class Atributos Nome do layer */ protected $nome; + /* + Variavel: $qyfile + + Nome do arquivo de seleção (.qy) + */ + public $qyfile; /* Function: __construct @@ -77,6 +83,7 @@ $tema - nome do tema function __construct($map_file,$tema="",$locaplic="") { //error_reporting(E_ALL); + $this->qyfile = str_replace(".map",".qy",$map_file); $this->locaplic = $locaplic; $this->mapa = ms_newMapObj($map_file); $this->arquivo = $map_file; @@ -214,8 +221,8 @@ $tipo - Tipo de busca brasil|null //le o arquivo de query se existir e checa se existe seleção para o tema $items = pegaItens($this->layer); $existesel = "nao"; - if (file_exists($this->arquivo."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} if ($this->layer->getNumresults() > 0){$existesel = "sim";} if ($existesel == "nao") {$this->layer->querybyrect($this->mapa->extent);} @@ -281,8 +288,8 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona else {$items[] = $itemtema;} $resultadoFinal[] = array("itens"=>$items); - if (file_exists($this->arquivo."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $indxlayer = $this->layer->index; $sopen = $this->layer->open(); if($sopen == MS_FAILURE){return "erro";} @@ -485,8 +492,8 @@ Include: if ($filtro != ""){$this->layer->setfilter("");} //le o arquivo de query se existir e checa se existe seleção para o tema $existesel = "nao"; - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} if ($this->layer->getNumresults() > 0){$existesel = "sim";} if ($existesel == "nao") {$this->layer->queryByrect($this->mapa->extent);} diff --git a/classesphp/classe_mapa.php b/classesphp/classe_mapa.php index 7153cc7..6dc1e69 100644 --- a/classesphp/classe_mapa.php +++ b/classesphp/classe_mapa.php @@ -53,6 +53,12 @@ class Mapa Objetos layers */ public $layers; + /* + Variavel: $qyfile + + Nome do arquivo de seleção (.qy) + */ + public $qyfile; /* Function: __construct @@ -71,6 +77,7 @@ $map_file - Endereço do mapfile no servidor. include_once($locaplic."/funcoes_gerais.php"); else include_once("funcoes_gerais.php"); + $this->qyfile = str_replace(".map",".qy",$map_file); $this->locaplic = $locaplic; if(!file_exists($map_file)) {return $this->arquivo = false;} @@ -140,9 +147,9 @@ string - javascript com os parametros function parametrosTemas() { $existesel = false; - $qy = file_exists(($this->arquivo)."qy"); + $qy = file_exists($this->qyfile); if ($qy) - {$this->mapa->loadquery(($this->arquivo)."qy");} + {$this->mapa->loadquery($this->qyfile);} foreach ($this->layers as $oLayer) { $sel = "nao"; @@ -218,7 +225,7 @@ string - javascript com os parametros } //apaga o arquivo qy se não for necessário if (!$existesel && $qy) - {unlink(($this->arquivo)."qy");} + {unlink($this->qyfile);} $temas = array_reverse($temas); return $temas; } @@ -247,7 +254,7 @@ Include: else include_once("classe_imagem.php"); $nomer = ""; - $qy = file_exists(($this->arquivo)."qy"); + $qy = file_exists($this->qyfile); $legenda = $this->mapa->legend; // //prepara a legenda para incluir no mapa, preenchendo os nomes das classes que podem estar em branco @@ -529,8 +536,8 @@ nome */ function listaTemasTipo($tipo,$selecao="nao") { - if (($selecao=="sim") && (file_exists(($this->arquivo)."qy"))) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (($selecao=="sim") && (file_exists($this->qyfile))) + {$this->mapa->loadquery($this->qyfile);} $layers = array(); foreach($this->layers as $layer) { @@ -585,14 +592,14 @@ nome { $layers = array(); $final = array(); - if (file_exists(($this->arquivo)."qy")) + if (file_exists($this->qyfile)) { foreach($this->layers as $layer) { if ($layer->getmetadata("ESCONDIDO") == "") {$layers[] = $layer;} } - $this->mapa->loadquery(($this->arquivo)."qy"); + $this->mapa->loadquery($this->qyfile); foreach ($layers as $layer) { //verifica se o tema tem selecao @@ -732,8 +739,8 @@ $incluitexto - sim|nao function gradeCoord($intervalo,$corlinha="200,200,200",$larguralinha=1,$tipolinha="linha",$tamanhotexto=MS_TINY,$fonte="bitmap",$cortexto="0,0,0",$incluitexto="sim",$mascara="-1,-1,-1",$shadowcolor="-1,-1,-1",$shadowsizex=0,$shadowsizey=0) { //echo $corlinha; - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} $nlayer = criaLayer($this->mapa,MS_LAYER_LINE,MS_DEFAULT,"Grade de coordenadas","SIM"); ms_newgridobj($nlayer); $nlayer->grid->set("labelformat", "DDMMSS"); @@ -815,8 +822,8 @@ $random - indica se os nomes dos novos layers serão modificados ou nao function adicionaTema($temas,$locaplic,$random="sim") { //limpa selecao - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} $temas = explode(",",$temas); $zoomlayer = ""; foreach ($temas as $nome) @@ -939,8 +946,8 @@ $temas - lista separada por vírgula dos temas que serão excluídos. */ function excluiTemas($temas) { - if (file_exists(($this->arquivo)."qy")) - {unlink(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink($this->qyfile);} $temas = explode(",",$temas); foreach ($temas as $nome) { @@ -1091,8 +1098,8 @@ Include: else include_once("wmswfs.php"); //limpa selecao - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} $nmap = ms_newMapObj($locaplic."/aplicmap/novotema.map"); $layer = $nmap->getlayerbyname("novotema"); //$layer->set("name",nomeRandomico()); diff --git a/classesphp/classe_selecao.php b/classesphp/classe_selecao.php index 0ebf194..60dc633 100644 --- a/classesphp/classe_selecao.php +++ b/classesphp/classe_selecao.php @@ -62,6 +62,12 @@ class Selecao Nome do layer */ protected $nome; + /* + Variavel: $qyfile + + Nome do arquivo de seleção (.qy) + */ + public $qyfile; /* Function: __construct @@ -77,6 +83,7 @@ $tema - nome do tema function __construct($map_file,$tema="") { //error_reporting(E_ALL); + $this->qyfile = str_replace(".map",".qy",$map_file); $this->mapa = ms_newMapObj($map_file); $this->arquivo = $map_file; if($tema != "" && @$this->mapa->getlayerbyname($tema)) @@ -116,8 +123,8 @@ $ys - lista de coordenadas y separadas por virgula {return($this->selecaoInverte());} $tipoLayer = $this->layer->type; $this->layer->set("template","none.htm"); - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $indxlayer = $this->layer->index; $res_count = $this->layer->getNumresults(); $shp_atual = array(); @@ -178,8 +185,8 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa $tipoLayero = $layero->type; $this->layer->set("template","none.htm"); $layero->set("template","none.htm"); - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $indxlayer = $this->layer->index; $res_count = $this->layer->getNumresults(); $res_counto = $layero->getNumresults(); @@ -338,8 +345,8 @@ $valor - Valor. } $this->layer->set("template","none.htm"); $indxlayer = $this->layer->index; - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $res_count = $this->layer->getNumresults(); $shp_atual = array(); for ($i = 0; $i < $res_count;++$i) @@ -403,8 +410,8 @@ $valor - Valor. if(!$this->layer){return "erro";} $this->layer->set("template","none.htm"); $indxlayer = $this->layer->index; - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $res_count = $this->layer->getNumresults(); $shp_atual = array(); for ($i = 0; $i < $res_count;++$i) @@ -458,8 +465,8 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa {return ($this->selecaoInverte());} if(!$this->layer){return "erro";} $this->layer->set("template","none.htm"); - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $indxlayer = $this->layer->index; $res_count = $this->layer->getNumresults(); $shp_atual = array(); @@ -534,16 +541,16 @@ Limpa a seleção do tema. if ($this->nome != "") //limpa de um tema { if(!$this->layer){return "erro";} - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $indxlayer = $this->layer->index; $this->mapa->freequery($indxlayer); - $this->mapa->savequery(($this->arquivo)."qy"); + $this->mapa->savequery($this->qyfile); } else //limpa de todos os temas { - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} } return("ok"); } @@ -557,8 +564,8 @@ Inverte seleção do tema. { if(!$this->layer){return "erro";} $this->layer->set("template","none.htm"); - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $indxlayer = $this->layer->index; $items = pegaItens($this->layer); $res_count = $this->layer->getNumresults(); @@ -584,7 +591,7 @@ Inverte seleção do tema. $this->mapa->freequery($indxlayer); foreach ($shp as $indx) {$this->mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} - $this->mapa->savequery(($this->arquivo)."qy"); + $this->mapa->savequery($this->qyfile); return("ok"); } /* @@ -607,7 +614,7 @@ $shp_atual - Indices dos elementos já selecionados. $this->mapa->freequery($indxlayer); foreach ($shp as $indx) {@$this->mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} - $this->mapa->savequery(($this->arquivo)."qy"); + $this->mapa->savequery($this->qyfile); return("ok"); } /* @@ -632,7 +639,7 @@ $shp_atual - Indices dos elementos já selecionados. $this->mapa->freequery($indxlayer); foreach ($shp as $indx) {$this->mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} - $this->mapa->savequery(($this->arquivo)."qy"); + $this->mapa->savequery($this->qyfile); return("ok"); } /* @@ -650,14 +657,14 @@ $ids - Ids separados por vírgula correspondendo aos registros. { if(!$this->layer){return "erro";} $this->layer->set("template","none.htm"); - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $ids = explode(",",$ids); $indxlayer = $this->layer->index; $ids = array_unique($ids); foreach ($ids as $i) {$this->mapa->queryByIndex($indxlayer, -1, $i);} - $this->mapa->savequery(($this->arquivo)."qy"); + $this->mapa->savequery($this->qyfile); return("ok"); } /* @@ -708,8 +715,8 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa if ($tipo == "inverte") {return ($this->selecaoInverte());} $this->layer->set("template","none.htm"); - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $indxlayer = $this->layer->index; $res_count = $this->layer->getNumresults(); $shp_atual = array(); @@ -757,8 +764,8 @@ $ext - coordenadas separadas por espaços no estilo xmin ymin xmax ymax if ($tipo == "inverte") {return ($this->selecaoInverte());} $this->layer->set("template","none.htm"); - if (file_exists(($this->arquivo)."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $indxlayer = $this->layer->index; $res_count = $this->layer->getNumresults(); $shp_atual = array(); diff --git a/classesphp/classe_temas.php b/classesphp/classe_temas.php index 1254095..5e35f1c 100644 --- a/classesphp/classe_temas.php +++ b/classesphp/classe_temas.php @@ -79,7 +79,13 @@ class Temas Indices dos layers do grupo */ - protected $indices; + protected $indices; + /* + Variavel: $qyfile + + Nome do arquivo de seleção (.qy) + */ + public $qyfile; /* function __construct @@ -93,6 +99,7 @@ $tema - nome do tema que será processado function __construct($map_file,$tema=null,$locaplic="") { //error_reporting(E_ALL); + $this->qyfile = str_replace(".map",".qy",$map_file); if(file_exists($locaplic."/funcoes_gerais.php")) include_once($locaplic."/funcoes_gerais.php"); else @@ -213,8 +220,8 @@ Altera a ordem de armazenamento dos layers no mapfile. */ function desceTema() { - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} $nl = $this->mapa->numlayers; $mover = 1; $indice = $this->indices[0]; @@ -259,8 +266,8 @@ Altera a ordem de armazenamento dos layers no mapfile. */ function sobeTema() { - if (file_exists(($this->arquivo)."qy")) - {unlink (($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {unlink ($this->qyfile);} $nl = $this->mapa->numlayers; $mover = 1; $indices = array_reverse($this->indices); @@ -692,8 +699,8 @@ $nome - nome que será dado a geometria $ext = $this->mapa->extent; $sb = $this->mapa->scalebar; $sb->set("status",MS_OFF); - if (file_exists($this->arquivo."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $items = pegaItens($this->layer); $sopen = $this->layer->open(); if($sopen == MS_FAILURE){return "erro";} @@ -917,8 +924,8 @@ Calcula a extensão geográfica dos elementos selecionados de um tema e ajusta o m $extatual = $this->mapa->extent; $prjMapa = ""; $prjTema = ""; - if (file_exists($this->arquivo."qy")) - {$this->mapa->loadquery(($this->arquivo)."qy");} + if (file_exists($this->qyfile)) + {$this->mapa->loadquery($this->qyfile);} $sopen = $this->layer->open(); if($sopen == MS_FAILURE){return "erro";} $res_count = $this->layer->getNumresults(); diff --git a/classesphp/funcoes_gerais.php b/classesphp/funcoes_gerais.php index af57f57..4057a44 100644 --- a/classesphp/funcoes_gerais.php +++ b/classesphp/funcoes_gerais.php @@ -1788,8 +1788,9 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) $novoshpf = ms_newShapefileObj($nomeshp.".shp", -2); //le o arquivo de query se existir e checa se existe seleção para o tema $existesel = "nao"; - if (file_exists($map_file."qy")) - {$map->loadquery($map_file."qy");} + $qyfile = str_replace(".map",".qy",$map_file); + if (file_exists($qyfile)) + {$map->loadquery($qyfile);} if ($layer->getNumresults() > 0) {$existesel = "sim";} diff --git a/classesphp/graficos.php b/classesphp/graficos.php index 9f057a9..1a69b0c 100644 --- a/classesphp/graficos.php +++ b/classesphp/graficos.php @@ -376,8 +376,9 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t //pega os valores $map = ms_newMapObj($map_file); $selecionados = "sim"; - if (file_exists($map_file."qy")) - {$map->loadquery($map_file."qy");} + $qyfile = str_replace(".map",".qy",$map_file); + if (file_exists($qyfile)) + {$map->loadquery($qyfile);} else {$selecionados = "nao";} $layer = $map->getLayerByName($tema); diff --git a/classesphp/mapa_controle.php b/classesphp/mapa_controle.php index 8ba5155..39bc24c 100644 --- a/classesphp/mapa_controle.php +++ b/classesphp/mapa_controle.php @@ -149,12 +149,7 @@ if (isset($debug) && $debug == "sim") // include_once ("carrega_ext.php"); include_once("funcoes_gerais.php"); -//include_once("../pacotes/cpaint/cpaint2.inc.php"); -// -//cria objeto cpaint para uso com ajax -// -//$cp = new cpaint(); -//$cp->set_data(""); + if ($funcao == "criaMapa") { session_destroy(); @@ -403,8 +398,9 @@ Salva o mapa acrescentando um novo layer com o buffer. $retorno = $m->criaBuffer($distancia,$locaplic,$unir); $m->salva(); //limpa selecao - if (file_exists($map_file."qy")) - {unlink ($map_file."qy");} + $qyfile = str_replace(".map",".qy",$map_file); + if (file_exists($qyfile)) + {unlink ($qyfile);} break; /* Property - DISTANCIAPTPT @@ -560,8 +556,10 @@ Valor: REINICIAMAPA Reinicia um mapa restaurando a cópia de segurança. */ case "REINICIAMAPA": - if(file_exists($map_file."qy")) - {unlink($map_file."qy");} + $qyfile = str_replace(".map",".qy",$map_file); + if (file_exists($qyfile)) + {unlink ($qyfile);} + unlink($map_file); copy(str_replace(".map","reinc.map",$map_file),$map_file); $retorno = "ok"; @@ -572,8 +570,10 @@ Valor: RECUPERAMAPA Recupera o mapfile de segurança. */ case "RECUPERAMAPA": - if(file_exists($map_file."qy")) - {unlink($map_file."qy");} + $qyfile = str_replace(".map",".qy",$map_file); + if (file_exists($qyfile)) + {unlink ($qyfile);} + unlink($map_file); $nmf = str_replace(".map","seguranca.map",$map_file); if(file_exists($nmf)) diff --git a/classesphp/mapa_inicia.php b/classesphp/mapa_inicia.php index d63903d..d465e95 100644 --- a/classesphp/mapa_inicia.php +++ b/classesphp/mapa_inicia.php @@ -157,6 +157,7 @@ function iniciaMapa() include_once("classe_mapa.php"); error_reporting(E_ALL); $m = new Mapa($map_file); + $m->mudaQS($w,$h); $m = new Mapa($map_file); $m->mapa->setsize($w,$h); @@ -200,7 +201,8 @@ function iniciaMapa() // //pega os parametros de cada tema // - $arqsel = (file_exists($map_file."qy")) ? true : false; + $qyfile = str_replace(".map",".qy",$map_file); + $arqsel = (file_exists($qyfile)) ? true : false; $m = New Mapa($map_file); $temas = $m->parametrosTemas(); $nomes = nomeRandomico(12); -- libgit2 0.21.2