Commit e619c589c46e335c167db30d8cdaa25155bcf082
1 parent
24a0ad3f
Exists in
master
Otimização das operações de seleção com a remoção de código antigo
Showing
1 changed file
with
19 additions
and
53 deletions
Show diff stats
classesphp/classe_selecao.php
| ... | ... | @@ -678,41 +678,22 @@ function: selecaoInverte |
| 678 | 678 | |
| 679 | 679 | Inverte seleção do tema. |
| 680 | 680 | */ |
| 681 | - function selecaoInverte() | |
| 682 | - { | |
| 683 | - if(!$this->layer){return "erro";} | |
| 684 | - $items = pegaItens($this->layer); | |
| 685 | - if (file_exists($this->qyfile)) | |
| 686 | - {$this->mapa->loadquery($this->qyfile);} | |
| 687 | - $indxlayer = $this->layer->index; | |
| 688 | - | |
| 689 | - /* | |
| 690 | - $res_count = $this->layer->getNumresults(); | |
| 691 | - $shp_atual = array(); | |
| 692 | - for ($i = 0; $i < $res_count;++$i) | |
| 693 | - { | |
| 694 | - $rc = $this->layer->getResult($i); | |
| 695 | - $shp_atual[] = $rc->shapeindex; | |
| 681 | + function selecaoInverte(){ | |
| 682 | + if(!$this->layer){ | |
| 683 | + return "erro"; | |
| 696 | 684 | } |
| 697 | - $this->mapa->freequery($indxlayer); | |
| 698 | - */ | |
| 699 | 685 | $shp_atual = array(); |
| 700 | - if($this->qyfileTema != "" && file_exists($this->qyfileTema)) | |
| 701 | - {$shp_atual = $this->unserializeQ($this->qyfileTema);} | |
| 702 | - | |
| 686 | + if($this->qyfileTema != "" && file_exists($this->qyfileTema)){ | |
| 687 | + $shp_atual = $this->unserializeQ($this->qyfileTema); | |
| 688 | + } | |
| 703 | 689 | $this->layer->queryByrect($this->mapa->extent); |
| 704 | 690 | $res_count = $this->layer->getNumresults(); |
| 705 | 691 | $shp_todos = array(); |
| 706 | - for ($i = 0; $i < $res_count;++$i) | |
| 707 | - { | |
| 692 | + for ($i = 0; $i < $res_count;++$i){ | |
| 708 | 693 | $rc = $this->layer->getResult($i); |
| 709 | 694 | $shp_todos[] = $rc->shapeindex; |
| 710 | 695 | } |
| 711 | 696 | $shp = array_diff($shp_todos,$shp_atual); |
| 712 | - $this->mapa->freequery($indxlayer); | |
| 713 | - foreach ($shp as $indx) | |
| 714 | - {$this->mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} | |
| 715 | - $this->mapa->savequery($this->qyfile); | |
| 716 | 697 | $this->serializeQ($this->qyfileTema,$shp); |
| 717 | 698 | return("ok"); |
| 718 | 699 | } |
| ... | ... | @@ -727,18 +708,13 @@ $shpi - Indices dos registros novos. |
| 727 | 708 | |
| 728 | 709 | $shp_atual - Indices dos elementos já selecionados. |
| 729 | 710 | */ |
| 730 | - function selecaoAdiciona($shpi,$shp_atual) | |
| 731 | - { | |
| 711 | + function selecaoAdiciona($shpi,$shp_atual){ | |
| 732 | 712 | error_reporting(0); |
| 733 | - if(!$this->layer){return "erro";} | |
| 734 | - $indxlayer = $this->layer->index; | |
| 713 | + if(!$this->layer){ | |
| 714 | + return "erro"; | |
| 715 | + } | |
| 735 | 716 | $shp = array_merge($shpi,$shp_atual); |
| 736 | 717 | $shp = array_unique($shp); |
| 737 | - | |
| 738 | - $this->mapa->freequery($indxlayer); | |
| 739 | - foreach ($shp as $indx) | |
| 740 | - {@$this->mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} | |
| 741 | - $this->mapa->savequery($this->qyfile); | |
| 742 | 718 | $this->serializeQ($this->qyfileTema,$shp); |
| 743 | 719 | return("ok"); |
| 744 | 720 | } |
| ... | ... | @@ -753,17 +729,12 @@ $shpi - Indices dos registros que ser&atilde;o retirados. |
| 753 | 729 | |
| 754 | 730 | $shp_atual - Indices dos elementos já selecionados. |
| 755 | 731 | */ |
| 756 | - function selecaoRetira($shpi,$shp_atual) | |
| 757 | - { | |
| 758 | - if(!$this->layer){return "erro";} | |
| 759 | - $indxlayer = $this->layer->index; | |
| 760 | - $this->mapa->freequery($indxlayer); | |
| 732 | + function selecaoRetira($shpi,$shp_atual){ | |
| 733 | + if(!$this->layer){ | |
| 734 | + return "erro"; | |
| 735 | + } | |
| 761 | 736 | $shp = array_diff($shp_atual,$shpi); |
| 762 | 737 | $shp = array_unique($shp); |
| 763 | - $this->mapa->freequery($indxlayer); | |
| 764 | - foreach ($shp as $indx) | |
| 765 | - {$this->mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} | |
| 766 | - $this->mapa->savequery($this->qyfile); | |
| 767 | 738 | $this->serializeQ($this->qyfileTema,$shp); |
| 768 | 739 | return("ok"); |
| 769 | 740 | } |
| ... | ... | @@ -778,17 +749,12 @@ parameters: |
| 778 | 749 | |
| 779 | 750 | $ids - Ids separados por vírgula correspondendo aos registros. |
| 780 | 751 | */ |
| 781 | - function incluiSel($ids) | |
| 782 | - { | |
| 783 | - if(!$this->layer){return "erro";} | |
| 784 | - if (file_exists($this->qyfile)) | |
| 785 | - {$this->mapa->loadquery($this->qyfile);} | |
| 752 | + function incluiSel($ids){ | |
| 753 | + if(!$this->layer){ | |
| 754 | + return "erro"; | |
| 755 | + } | |
| 786 | 756 | $ids = explode(",",$ids); |
| 787 | - $indxlayer = $this->layer->index; | |
| 788 | 757 | $ids = array_unique($ids); |
| 789 | - foreach ($ids as $i) | |
| 790 | - {$this->mapa->queryByIndex($indxlayer, -1, $i);} | |
| 791 | - $this->mapa->savequery($this->qyfile); | |
| 792 | 758 | $this->serializeQ($this->qyfileTema,$ids); |
| 793 | 759 | return("ok"); |
| 794 | 760 | } | ... | ... |