Commit 4e87f248b14af966dcf90cd162c2bd73d66f55db
1 parent
9eee52da
Exists in
master
and in
6 other branches
Otimização do uso de memória do servidor ao criar classes por valores únicos no editor de legenda
Showing
1 changed file
with
52 additions
and
27 deletions
Show diff stats
classesphp/classe_alteraclasse.php
| @@ -752,16 +752,16 @@ class Alteraclasse | @@ -752,16 +752,16 @@ class Alteraclasse | ||
| 752 | if ($itemNome == "" || $ignorar != "") { | 752 | if ($itemNome == "" || $ignorar != "") { |
| 753 | $itemNome = $item; | 753 | $itemNome = $item; |
| 754 | } | 754 | } |
| 755 | - // pega valores | ||
| 756 | - $vs = $this->pegaValores($this->mapa, $this->layer, $item, false, $ignorar); | ||
| 757 | if ($item == $itemNome) { | 755 | if ($item == $itemNome) { |
| 758 | - $ns = $vs; | 756 | + $vs = $this->pegaValores($this->mapa, $this->layer, $item, false, $ignorar,true); |
| 757 | + for ($i = 0; $i < count($vs); ++ $i) { | ||
| 758 | + $temp[$vs[$i]] = $vs[$i]; | ||
| 759 | + } | ||
| 759 | } else { | 760 | } else { |
| 760 | - $ns = $this->pegaValores($this->mapa, $this->layer, $itemNome, false, $ignorar); | ||
| 761 | - } | ||
| 762 | - $lista = array(); | ||
| 763 | - for ($i = 0; $i < count($vs); ++ $i) { | ||
| 764 | - $temp[$vs[$i]] = $ns[$i]; | 761 | + $vs = $this->pegaValores($this->mapa, $this->layer, array($item,$itemNome), false, $ignorar,true); |
| 762 | + for ($i = 0; $i < count($vs); ++ $i) { | ||
| 763 | + $temp[$vs[$i][0]] = $vs[$i][1]; | ||
| 764 | + } | ||
| 765 | } | 765 | } |
| 766 | $valores = array_keys($temp); | 766 | $valores = array_keys($temp); |
| 767 | $nomes = array(); | 767 | $nomes = array(); |
| @@ -784,7 +784,7 @@ class Alteraclasse | @@ -784,7 +784,7 @@ class Alteraclasse | ||
| 784 | } | 784 | } |
| 785 | $c = $this->layer->numclasses; | 785 | $c = $this->layer->numclasses; |
| 786 | for ($i = 0; $i < $c; ++ $i) // apaga classes atuais | 786 | for ($i = 0; $i < $c; ++ $i) // apaga classes atuais |
| 787 | -{ | 787 | + { |
| 788 | $cl = $this->layer->getClass($i); | 788 | $cl = $this->layer->getClass($i); |
| 789 | $cl->set("status", MS_DELETE); | 789 | $cl->set("status", MS_DELETE); |
| 790 | } | 790 | } |
| @@ -1161,7 +1161,7 @@ class Alteraclasse | @@ -1161,7 +1161,7 @@ class Alteraclasse | ||
| 1161 | * | 1161 | * |
| 1162 | * {array} | 1162 | * {array} |
| 1163 | */ | 1163 | */ |
| 1164 | - function pegaValores($mapa, $layer, $item, $numerico = false, $ignorar = "") | 1164 | + function pegaValores($mapa, $layer, $item, $numerico = false, $ignorar = "",$unico=false) |
| 1165 | { | 1165 | { |
| 1166 | $layer->set("template", "none.htm"); | 1166 | $layer->set("template", "none.htm"); |
| 1167 | // $layer->setfilter(""); | 1167 | // $layer->setfilter(""); |
| @@ -1174,7 +1174,6 @@ class Alteraclasse | @@ -1174,7 +1174,6 @@ class Alteraclasse | ||
| 1174 | $item = "value_0"; | 1174 | $item = "value_0"; |
| 1175 | } | 1175 | } |
| 1176 | } | 1176 | } |
| 1177 | - | ||
| 1178 | $sopen = $layer->open(); | 1177 | $sopen = $layer->open(); |
| 1179 | if ($sopen == MS_FAILURE) { | 1178 | if ($sopen == MS_FAILURE) { |
| 1180 | return "erro"; | 1179 | return "erro"; |
| @@ -1189,26 +1188,29 @@ class Alteraclasse | @@ -1189,26 +1188,29 @@ class Alteraclasse | ||
| 1189 | $shp_index = $result->shapeindex; | 1188 | $shp_index = $result->shapeindex; |
| 1190 | $shape = $layer->getfeature($shp_index, - 1); | 1189 | $shape = $layer->getfeature($shp_index, - 1); |
| 1191 | } | 1190 | } |
| 1192 | - $v = trim($shape->values[$item]); | ||
| 1193 | - if ($numerico) { | ||
| 1194 | - if (is_numeric($v)) { | ||
| 1195 | - if ($ignorar == "") { | ||
| 1196 | - $valitem[] = $v; | ||
| 1197 | - } else { | ||
| 1198 | - // if ($v != $ignorar) | ||
| 1199 | - if (! in_array($v, $ignorararray)) { | ||
| 1200 | - $valitem[] = $v; | ||
| 1201 | - } | 1191 | + if(is_array($item)){ |
| 1192 | + $valite = array(); | ||
| 1193 | + foreach($item as $ite){ | ||
| 1194 | + $valite[] = $this->retornaValorShape($shape,$ite,$numerico,$ignorararray); | ||
| 1195 | + } | ||
| 1196 | + if($unico == true){ | ||
| 1197 | + if(!in_array($valite,$valitem)){ | ||
| 1198 | + $valitem[] = $valite; | ||
| 1202 | } | 1199 | } |
| 1203 | } | 1200 | } |
| 1201 | + else { | ||
| 1202 | + $valitem[] = $valite; | ||
| 1203 | + } | ||
| 1204 | } else { | 1204 | } else { |
| 1205 | - if ($ignorar == "") { | ||
| 1206 | - $valitem[] = $v; | ||
| 1207 | - } else { | ||
| 1208 | - if (! in_array($v, $ignorararray)) { | ||
| 1209 | - $valitem[] = $v; | 1205 | + $valite = $this->retornaValorShape($shape,$item,$numerico,$ignorararray); |
| 1206 | + if($unico == true){ | ||
| 1207 | + if(!in_array($valite,$valitem)){ | ||
| 1208 | + $valitem[] = $valite; | ||
| 1210 | } | 1209 | } |
| 1211 | } | 1210 | } |
| 1211 | + else { | ||
| 1212 | + $valitem[] = $valite; | ||
| 1213 | + } | ||
| 1212 | } | 1214 | } |
| 1213 | } | 1215 | } |
| 1214 | $fechou = $layer->close(); | 1216 | $fechou = $layer->close(); |
| @@ -1216,7 +1218,30 @@ class Alteraclasse | @@ -1216,7 +1218,30 @@ class Alteraclasse | ||
| 1216 | $layer->close(); | 1218 | $layer->close(); |
| 1217 | return ($valitem); | 1219 | return ($valitem); |
| 1218 | } | 1220 | } |
| 1219 | - | 1221 | + function retornaValorShape($shape,$item,$numerico,$ignorararray){ |
| 1222 | + $v = trim($shape->values[$item]); | ||
| 1223 | + $valor = ""; | ||
| 1224 | + if ($numerico) { | ||
| 1225 | + if (is_numeric($v)) { | ||
| 1226 | + if (count($ignorararray) == 0) { | ||
| 1227 | + $valor = $v; | ||
| 1228 | + } else { | ||
| 1229 | + if (! in_array($v, $ignorararray)) { | ||
| 1230 | + $valor = $v; | ||
| 1231 | + } | ||
| 1232 | + } | ||
| 1233 | + } | ||
| 1234 | + } else { | ||
| 1235 | + if (count($ignorararray) == 0) { | ||
| 1236 | + $valor = $v; | ||
| 1237 | + } else { | ||
| 1238 | + if (! in_array($v, $ignorararray)) { | ||
| 1239 | + $valor = $v; | ||
| 1240 | + } | ||
| 1241 | + } | ||
| 1242 | + } | ||
| 1243 | + return $valor; | ||
| 1244 | + } | ||
| 1220 | /* | 1245 | /* |
| 1221 | * Function: converteTexto | 1246 | * Function: converteTexto |
| 1222 | * | 1247 | * |