Commit 71705442391d9f5f9a6f634bede4e1d332b00229
1 parent
86d7705f
Exists in
master
and in
7 other branches
Substituição da função loadquery por uma nova existente em classesphp/funcoes_gerais.php
Showing
7 changed files
with
45 additions
and
85 deletions
Show diff stats
classesphp/classe_analise.php
| ... | ... | @@ -960,10 +960,7 @@ $locaplic - Localização do I3geo. |
| 960 | 960 | $nomeshp = $this->diretorio."/".$nomefinal; |
| 961 | 961 | //pega os shapes selecionados |
| 962 | 962 | $itemspt = pegaItens($layerPt); |
| 963 | - $existesel = "nao"; | |
| 964 | - if (file_exists($this->qyfile)) | |
| 965 | - {$this->mapa->loadquery($this->qyfile);} | |
| 966 | - if ($layerPt->getNumresults() > 0){$existesel = "sim";} | |
| 963 | + $existesel = carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 967 | 964 | if ($existesel == "nao") |
| 968 | 965 | { |
| 969 | 966 | if($layerPt->getProjection() == "" ) |
| ... | ... | @@ -1111,9 +1108,8 @@ function distanciaptpt($temaorigem,$temadestino,$temaoverlay,$locaplic,$itemorig |
| 1111 | 1108 | //define o nome do novo shapefile que será criado |
| 1112 | 1109 | $nomefinal = nomeRandomico(); |
| 1113 | 1110 | $nomeshp = $this->diretorio."/".$nomefinal; |
| 1114 | - if (file_exists($this->qyfile)) | |
| 1115 | - {$this->mapa->loadquery($this->qyfile);} | |
| 1116 | - else | |
| 1111 | + $existesel = carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 1112 | + if ($existesel == "nao") | |
| 1117 | 1113 | {return "errox";} |
| 1118 | 1114 | $layerorigem = $this->mapa->getlayerbyname($temaorigem); |
| 1119 | 1115 | $layerdestino = $this->mapa->getlayerbyname($temadestino); |
| ... | ... | @@ -1237,8 +1233,7 @@ nome do layer criado com o buffer. |
| 1237 | 1233 | $nomebuffer = nomeRandomico(); |
| 1238 | 1234 | $nomeshp = $this->diretorio."/".$nomebuffer; |
| 1239 | 1235 | //pega os shapes selecionados |
| 1240 | - if (file_exists($this->qyfile)) | |
| 1241 | - {$this->mapa->loadquery($this->qyfile);} | |
| 1236 | + carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 1242 | 1237 | $sopen = $this->layer->open(); |
| 1243 | 1238 | if($sopen == MS_FAILURE){return "erro";} |
| 1244 | 1239 | $items = pegaItens($this->layer); |
| ... | ... | @@ -1349,8 +1344,7 @@ $locaplic - Localização do I3geo. |
| 1349 | 1344 | $nomeCentroides = nomeRandomico(); |
| 1350 | 1345 | $nomeshp = $this->diretorio."/".$nomeCentroides; |
| 1351 | 1346 | //pega os shapes selecionados |
| 1352 | - if (file_exists($this->qyfile)) | |
| 1353 | - {$this->mapa->loadquery($this->qyfile);} | |
| 1347 | + carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 1354 | 1348 | $sopen = $this->layer->open(); |
| 1355 | 1349 | if($sopen == MS_FAILURE){return "erro";} |
| 1356 | 1350 | $items = pegaItens($this->layer); |
| ... | ... | @@ -1923,8 +1917,7 @@ Salva o mapa acrescentando um novo layer com o resultado. |
| 1923 | 1917 | else |
| 1924 | 1918 | include_once "../pacotes/phpxbase/api_conversion.php"; |
| 1925 | 1919 | //define o nome do novo shapefile que será criado |
| 1926 | - if (file_exists($this->qyfile)) | |
| 1927 | - {$this->mapa->loadquery($this->qyfile);} | |
| 1920 | + carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 1928 | 1921 | $sopen = $this->layer->open(); |
| 1929 | 1922 | if($sopen == MS_FAILURE){return "erro";} |
| 1930 | 1923 | $res_count = $this->layer->getNumresults(); |
| ... | ... | @@ -2043,8 +2036,7 @@ $locaplic - Localização do I3geo |
| 2043 | 2036 | else |
| 2044 | 2037 | include_once "../pacotes/phpxbase/api_conversion.php"; |
| 2045 | 2038 | //define o nome do novo shapefile que será criado |
| 2046 | - if (file_exists($this->qyfile)) | |
| 2047 | - {$this->mapa->loadquery($this->qyfile);} | |
| 2039 | + carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 2048 | 2040 | $sopen = $this->layer->open(); |
| 2049 | 2041 | if($sopen == MS_FAILURE){return "erro";} |
| 2050 | 2042 | $res_count = $this->layer->getNumresults(); |
| ... | ... | @@ -2435,10 +2427,7 @@ function gravaCoordenadasPt($tema,$limitepontos="TRUE",$extendelimite) |
| 2435 | 2427 | $nomefinal = nomeRandomico(); |
| 2436 | 2428 | $nomearq = $this->diretorio."/".$nomefinal; |
| 2437 | 2429 | $itemspt = pegaItens($layerPt); |
| 2438 | - $existesel = "nao"; | |
| 2439 | - if (file_exists($this->qyfile)) | |
| 2440 | - {$this->mapa->loadquery($this->qyfile);} | |
| 2441 | - if ($layerPt->getNumresults() > 0){$existesel = "sim";} | |
| 2430 | + $existesel = carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 2442 | 2431 | if ($existesel == "nao") |
| 2443 | 2432 | { |
| 2444 | 2433 | if($layerPt->getProjection() == "" ) | ... | ... |
classesphp/classe_atributos.php
| ... | ... | @@ -87,6 +87,11 @@ $ext - (opcional) extensão geográfica que será aplicada ao mapa |
| 87 | 87 | function __construct($map_file,$tema="",$locaplic="",$ext="") |
| 88 | 88 | { |
| 89 | 89 | //error_reporting(E_ALL); |
| 90 | + if (!function_exists('ms_newMapObj')) {return false;} | |
| 91 | + if(file_exists($locaplic."/funcoes_gerais.php")) | |
| 92 | + include_once($locaplic."/funcoes_gerais.php"); | |
| 93 | + else | |
| 94 | + include_once("funcoes_gerais.php"); | |
| 90 | 95 | $this->qyfile = str_replace(".map",".qy",$map_file); |
| 91 | 96 | $this->locaplic = $locaplic; |
| 92 | 97 | $this->mapa = ms_newMapObj($map_file); |
| ... | ... | @@ -239,10 +244,7 @@ $tipo - Tipo de busca brasil|null |
| 239 | 244 | $this->layer->setfilter(""); |
| 240 | 245 | //le o arquivo de query se existir e checa se existe seleção para o tema |
| 241 | 246 | $items = pegaItens($this->layer); |
| 242 | - $existesel = "nao"; | |
| 243 | - if (file_exists($this->qyfile)) | |
| 244 | - {$this->mapa->loadquery($this->qyfile);} | |
| 245 | - if ($this->layer->getNumresults() > 0){$existesel = "sim";} | |
| 247 | + $existesel = carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 246 | 248 | if ($existesel == "nao") |
| 247 | 249 | {$this->layer->querybyrect($this->mapa->extent);} |
| 248 | 250 | $sopen = $this->layer->open(); |
| ... | ... | @@ -306,8 +308,7 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona |
| 306 | 308 | else |
| 307 | 309 | {$items[] = $itemtema;} |
| 308 | 310 | $resultadoFinal[] = array("itens"=>$items); |
| 309 | - if (file_exists($this->qyfile)) | |
| 310 | - {$this->mapa->loadquery($this->qyfile);} | |
| 311 | + carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 311 | 312 | $indxlayer = $this->layer->index; |
| 312 | 313 | $sopen = $this->layer->open(); |
| 313 | 314 | if($sopen == MS_FAILURE){return "erro";} |
| ... | ... | @@ -506,10 +507,7 @@ Include: |
| 506 | 507 | $filtro = $this->layer->getfilterstring(); |
| 507 | 508 | if ($filtro != ""){$this->layer->setfilter("");} |
| 508 | 509 | //le o arquivo de query se existir e checa se existe seleção para o tema |
| 509 | - $existesel = "nao"; | |
| 510 | - if (file_exists($this->qyfile)) | |
| 511 | - {$this->mapa->loadquery($this->qyfile);} | |
| 512 | - if ($this->layer->getNumresults() > 0){$existesel = "sim";} | |
| 510 | + $existesel = carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 513 | 511 | if ($existesel == "nao") |
| 514 | 512 | {$this->layer->queryByrect($this->mapa->extent);} |
| 515 | 513 | $sopen = $this->layer->open(); | ... | ... |
classesphp/classe_mapa.php
| ... | ... | @@ -170,26 +170,11 @@ string - javascript com os parametros |
| 170 | 170 | //$qy = file_exists($this->qyfile); |
| 171 | 171 | foreach($this->layers as $l) |
| 172 | 172 | {$l->set("template","none.htm");} |
| 173 | - | |
| 174 | - //if ($qy) | |
| 175 | - //{$this->mapa->loadquery($this->qyfile);} | |
| 176 | 173 | foreach ($this->layers as $oLayer) |
| 177 | 174 | { |
| 178 | 175 | $sel = "nao"; |
| 179 | 176 | if(file_exists($dir."/".$oLayer->name.".php")) |
| 180 | 177 | {$sel = "sim";$existesel = true;} |
| 181 | - /* | |
| 182 | - if ($qy) //verifica se existe alguma selecao no tema | |
| 183 | - { | |
| 184 | - $sopen = $oLayer->open(); | |
| 185 | - if($sopen != MS_FAILURE) | |
| 186 | - { | |
| 187 | - $res_count = $oLayer->getNumresults(); | |
| 188 | - $oLayer->close(); | |
| 189 | - if ($res_count > 0){$sel = "sim";$existesel = true;} | |
| 190 | - } | |
| 191 | - } | |
| 192 | - */ | |
| 193 | 178 | $escondido = $oLayer->getmetadata("escondido"); |
| 194 | 179 | if($escondido == "") |
| 195 | 180 | {$escondido = "nao";} |
| ... | ... | @@ -294,8 +279,10 @@ Include: |
| 294 | 279 | if($qy) |
| 295 | 280 | { |
| 296 | 281 | foreach($this->layers as $l) |
| 297 | - {$l->set("template","none.htm");} | |
| 298 | - $this->mapa->loadquery($this->qyfile); | |
| 282 | + { | |
| 283 | + $l->set("template","none.htm"); | |
| 284 | + carregaquery($this->arquivo,&$l,&$this->mapa); | |
| 285 | + } | |
| 299 | 286 | } |
| 300 | 287 | $legenda = $this->mapa->legend; |
| 301 | 288 | // | ... | ... |
classesphp/classe_temas.php
| ... | ... | @@ -104,6 +104,7 @@ $ext - (opcional) extensão geográfica que será aplicada ao mapa |
| 104 | 104 | { |
| 105 | 105 | //error_reporting(E_ALL); |
| 106 | 106 | $this->qyfile = str_replace(".map",".qy",$map_file); |
| 107 | + $this->arquivo = $map_file; | |
| 107 | 108 | if(file_exists($locaplic."/funcoes_gerais.php")) |
| 108 | 109 | include_once($locaplic."/funcoes_gerais.php"); |
| 109 | 110 | else |
| ... | ... | @@ -745,8 +746,7 @@ $nome - nome que será dado a geometria |
| 745 | 746 | $ext = $this->mapa->extent; |
| 746 | 747 | $sb = $this->mapa->scalebar; |
| 747 | 748 | $sb->set("status",MS_OFF); |
| 748 | - if (file_exists($this->qyfile)) | |
| 749 | - {$this->mapa->loadquery($this->qyfile);} | |
| 749 | + carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 750 | 750 | $items = pegaItens($this->layer); |
| 751 | 751 | $sopen = $this->layer->open(); |
| 752 | 752 | if($sopen == MS_FAILURE){return "erro";} |
| ... | ... | @@ -970,8 +970,7 @@ Calcula a extensão geográfica dos elementos selecionados de um tema e ajusta o m |
| 970 | 970 | $extatual = $this->mapa->extent; |
| 971 | 971 | $prjMapa = ""; |
| 972 | 972 | $prjTema = ""; |
| 973 | - if (file_exists($this->qyfile)) | |
| 974 | - {$this->mapa->loadquery($this->qyfile);} | |
| 973 | + carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 975 | 974 | $sopen = $this->layer->open(); |
| 976 | 975 | if($sopen == MS_FAILURE){return "erro";} |
| 977 | 976 | $res_count = $this->layer->getNumresults(); | ... | ... |
classesphp/funcoes_gerais.php
| ... | ... | @@ -1830,12 +1830,7 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) |
| 1830 | 1830 | $reg = array(); |
| 1831 | 1831 | $novoshpf = ms_newShapefileObj($nomeshp.".shp", -2); |
| 1832 | 1832 | //le o arquivo de query se existir e checa se existe seleção para o tema |
| 1833 | - $existesel = "nao"; | |
| 1834 | - if (file_exists($map_file."qy")) | |
| 1835 | - {$map->loadquery($map_file."qy");} | |
| 1836 | - if ($layer->getNumresults() > 0) | |
| 1837 | - {$existesel = "sim";} | |
| 1838 | - | |
| 1833 | + $existesel = carregaquery($map_file,&$layer,&$map); | |
| 1839 | 1834 | if ($existesel == "nao") |
| 1840 | 1835 | {@$layer->queryByrect($map->extent);} |
| 1841 | 1836 | |
| ... | ... | @@ -2626,5 +2621,20 @@ function removeLinha($texto,$mapfile) |
| 2626 | 2621 | {$escreve = fwrite ($abre,$linha);} |
| 2627 | 2622 | $fecha = fclose ($abre); |
| 2628 | 2623 | } |
| 2629 | - | |
| 2624 | +function carregaquery($mapfile,$objlayer,$objmapa) | |
| 2625 | +{ | |
| 2626 | + $qyfile = dirname($mapfile)."/".$objlayer->name.".php"; | |
| 2627 | + if(file_exists($qyfile)) | |
| 2628 | + { | |
| 2629 | + $indxlayer = $objlayer->index; | |
| 2630 | + $handle = fopen ($qyfile, "r"); | |
| 2631 | + $conteudo = fread ($handle, filesize ($qyfile)); | |
| 2632 | + fclose ($handle); | |
| 2633 | + $shp = unserialize($conteudo); | |
| 2634 | + foreach ($shp as $indx) | |
| 2635 | + {$objmapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} | |
| 2636 | + return "sim"; | |
| 2637 | + } | |
| 2638 | + return "nao"; | |
| 2639 | +} | |
| 2630 | 2640 | ?> |
| 2631 | 2641 | \ No newline at end of file | ... | ... |
classesphp/graficos.php
| ... | ... | @@ -386,21 +386,8 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t |
| 386 | 386 | $extatual = $map->extent; |
| 387 | 387 | $extatual->setextent((min($e[0],$e[2])),(min($e[1],$e[3])),(max($e[0],$e[2])),(max($e[1],$e[3]))); |
| 388 | 388 | } |
| 389 | - $selecionados = "sim"; | |
| 390 | - $qyfile = str_replace(".map",".qy",$map_file); | |
| 391 | - if (file_exists($qyfile)) | |
| 392 | - {$map->loadquery($qyfile);} | |
| 393 | - else | |
| 394 | - {$selecionados = "nao";} | |
| 395 | 389 | $layer = $map->getLayerByName($tema); |
| 396 | - if ($selecionados == "sim") | |
| 397 | - { | |
| 398 | - $layer->open(); | |
| 399 | - $res_count = $layer->getNumresults(); | |
| 400 | - $layer->close(); | |
| 401 | - if ($res_count < 1) | |
| 402 | - {$selecionados = "nao";} | |
| 403 | - } | |
| 390 | + $selecionados = carregaquery($map_file,&$layer,&$map); | |
| 404 | 391 | if ($exclui == ""){$exclui = "nulo";} |
| 405 | 392 | $valores = pegaValoresM($map,$layer,array($itemclasses,$itemvalores),$exclui,$selecionados); |
| 406 | 393 | $dados = agrupaValores($valores,0,1,$tipo); |
| ... | ... | @@ -442,21 +429,8 @@ function dadosLinhaDoTempo($map_file,$tema,$ext="") |
| 442 | 429 | $extatual = $map->extent; |
| 443 | 430 | $extatual->setextent((min($e[0],$e[2])),(min($e[1],$e[3])),(max($e[0],$e[2])),(max($e[1],$e[3]))); |
| 444 | 431 | } |
| 445 | - $selecionados = "sim"; | |
| 446 | - $qyfile = str_replace(".map",".qy",$map_file); | |
| 447 | - if (file_exists($qyfile)) | |
| 448 | - {$map->loadquery($qyfile);} | |
| 449 | - else | |
| 450 | - {$selecionados = "nao";} | |
| 451 | 432 | $layer = $map->getLayerByName($tema); |
| 452 | - if ($selecionados == "sim") | |
| 453 | - { | |
| 454 | - $layer->open(); | |
| 455 | - $res_count = $layer->getNumresults(); | |
| 456 | - $layer->close(); | |
| 457 | - if ($res_count < 1) | |
| 458 | - {$selecionados = "nao";} | |
| 459 | - } | |
| 433 | + $selecionados = carregaquery($map_file,&$layer,&$map); | |
| 460 | 434 | if ($exclui == ""){$exclui = "nulo";} |
| 461 | 435 | //define os itens para pegar os dados |
| 462 | 436 | $itens = array(); | ... | ... |
ferramentas/tabela/relatorio.php
| ... | ... | @@ -42,8 +42,11 @@ if($ext && $ext != ""){ |
| 42 | 42 | $layer = $mapa->getlayerbyname($temarel); |
| 43 | 43 | $layer->set("template","none.html"); |
| 44 | 44 | $existesel = "nao"; |
| 45 | +/* | |
| 45 | 46 | if (file_exists($map_file."qy")) |
| 46 | 47 | {$mapa->loadquery($map_file."qy");} |
| 48 | +*/ | |
| 49 | +carregaquery($map_file,&$layer,&$mapa); | |
| 47 | 50 | if ($layer->getNumresults() > 0){$existesel = "sim";} |
| 48 | 51 | if ($existesel == "nao") |
| 49 | 52 | {$layer->querybyrect($mapa->extent);} | ... | ... |