Commit 91687e3b9e168028e49f757b4fd6e5bf2f6695fd
1 parent
f1312106
Exists in
master
and in
7 other branches
Correção na obtenção de dados para geração dos gráficos
Showing
1 changed file
with
16 additions
and
7 deletions
Show diff stats
classesphp/graficos.php
@@ -401,7 +401,9 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t | @@ -401,7 +401,9 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t | ||
401 | //agrupa se for o caso | 401 | //agrupa se for o caso |
402 | $dados = agrupaValores($valores,0,1,$tipo); | 402 | $dados = agrupaValores($valores,0,1,$tipo); |
403 | foreach($valores as $valor){ | 403 | foreach($valores as $valor){ |
404 | - $cores[$valor[0]] = $valor["cores"]; | 404 | + if(!empty($valor[0])){ |
405 | + $cores[$valor[0]] = $valor["cores"]; | ||
406 | + } | ||
405 | } | 407 | } |
406 | //calcula os parametros para o grafico | 408 | //calcula os parametros para o grafico |
407 | $nval = count($dados); | 409 | $nval = count($dados); |
@@ -412,7 +414,7 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t | @@ -412,7 +414,7 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t | ||
412 | $nnval[] = "n;x"; | 414 | $nnval[] = "n;x"; |
413 | if ($tipo != "xy"){ | 415 | if ($tipo != "xy"){ |
414 | for ($i=0;$i < $nval; ++$i){ | 416 | for ($i=0;$i < $nval; ++$i){ |
415 | - if ($dados[$tempm[$i]] > 0){ | 417 | + if ($tempm[$i] != "" && $dados[$tempm[$i]] > 0){ |
416 | $pp = ($dados[$tempm[$i]] * 100) / $soma; | 418 | $pp = ($dados[$tempm[$i]] * 100) / $soma; |
417 | if ($percentual == "TRUE"){ | 419 | if ($percentual == "TRUE"){ |
418 | $temp = "'".$tempm[$i]." (".round($pp,0)."%)';".$dados[$tempm[$i]]; | 420 | $temp = "'".$tempm[$i]." (".round($pp,0)."%)';".$dados[$tempm[$i]]; |
@@ -429,6 +431,7 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t | @@ -429,6 +431,7 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t | ||
429 | $tempval[] = $temp; | 431 | $tempval[] = $temp; |
430 | } | 432 | } |
431 | } | 433 | } |
434 | + $nval = count($tempval); | ||
432 | } | 435 | } |
433 | else{ | 436 | else{ |
434 | foreach ($valores as $v){ | 437 | foreach ($valores as $v){ |
@@ -459,13 +462,13 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t | @@ -459,13 +462,13 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t | ||
459 | function dadosLinhaDoTempo($map_file,$tema,$ext="") | 462 | function dadosLinhaDoTempo($map_file,$tema,$ext="") |
460 | { | 463 | { |
461 | $map = ms_newMapObj($map_file); | 464 | $map = ms_newMapObj($map_file); |
462 | - | 465 | + |
463 | if($ext && $ext != ""){ | 466 | if($ext && $ext != ""){ |
464 | $e = explode(" ",$ext); | 467 | $e = explode(" ",$ext); |
465 | $extatual = $map->extent; | 468 | $extatual = $map->extent; |
466 | $extatual->setextent((min($e[0],$e[2])),(min($e[1],$e[3])),(max($e[0],$e[2])),(max($e[1],$e[3]))); | 469 | $extatual->setextent((min($e[0],$e[2])),(min($e[1],$e[3])),(max($e[0],$e[2])),(max($e[1],$e[3]))); |
467 | } | 470 | } |
468 | - | 471 | + |
469 | $layer = $map->getLayerByName($tema); | 472 | $layer = $map->getLayerByName($tema); |
470 | $selecionados = carregaquery2($map_file,$layer,$map); | 473 | $selecionados = carregaquery2($map_file,$layer,$map); |
471 | if ($exclui == ""){$exclui = "nulo";} | 474 | if ($exclui == ""){$exclui = "nulo";} |
@@ -685,6 +688,7 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$ch | @@ -685,6 +688,7 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$ch | ||
685 | $sopen = $layer->open(); | 688 | $sopen = $layer->open(); |
686 | if($sopen == MS_FAILURE){return "erro";} | 689 | if($sopen == MS_FAILURE){return "erro";} |
687 | $res_count = $layer->getNumresults(); | 690 | $res_count = $layer->getNumresults(); |
691 | + //echo $res_count;echo "\n"; | ||
688 | for ($i=0;$i<$res_count;++$i){ | 692 | for ($i=0;$i<$res_count;++$i){ |
689 | if($versao == 6){ | 693 | if($versao == 6){ |
690 | $shape = $layer->getShape($layer->getResult($i)); | 694 | $shape = $layer->getShape($layer->getResult($i)); |
@@ -718,6 +722,7 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$ch | @@ -718,6 +722,7 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$ch | ||
718 | {$v[$item] = $vitem;} | 722 | {$v[$item] = $vitem;} |
719 | } | 723 | } |
720 | //pega o centroide | 724 | //pega o centroide |
725 | + //echo $i;echo "\n"; | ||
721 | if($centroide == true){ | 726 | if($centroide == true){ |
722 | $c = $shape->getCentroid(); | 727 | $c = $shape->getCentroid(); |
723 | if (($prjTema != "") && ($prjMapa != $prjTema)){ | 728 | if (($prjTema != "") && ($prjMapa != $prjTema)){ |
@@ -727,11 +732,15 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$ch | @@ -727,11 +732,15 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$ch | ||
727 | } | 732 | } |
728 | $v["centroide"] = "POINT(".$c->x." ".$c->y.")"; | 733 | $v["centroide"] = "POINT(".$c->x." ".$c->y.")"; |
729 | } | 734 | } |
735 | + //echo $i;echo "---\n"; | ||
730 | //pega a cor da classe onde cai o registro | 736 | //pega a cor da classe onde cai o registro |
731 | if($nclasses > 0 && $versao >= 6){ | 737 | if($nclasses > 0 && $versao >= 6){ |
732 | - $classe = $layer->getclass($layer->getClassIndex($shape)); | ||
733 | - $cor = $classe->getstyle(0)->color; | ||
734 | - $v["cores"] = $cor->red." ".$cor->green." ".$cor->blue; | 738 | + $cx = $layer->getClassIndex($shape); |
739 | + if($cx > -1){ | ||
740 | + $classe = $layer->getclass($cx); | ||
741 | + $cor = $classe->getstyle(0)->color; | ||
742 | + $v["cores"] = $cor->red." ".$cor->green." ".$cor->blue; | ||
743 | + } | ||
735 | } | 744 | } |
736 | if (count($v) == 1){ | 745 | if (count($v) == 1){ |
737 | $valores[] = $v[0]; | 746 | $valores[] = $v[0]; |