Commit 4fef75cd756038949b75915d763ee0874d8f9268
1 parent
df4077b3
Exists in
master
and in
7 other branches
inclusão de um novo método na classe selecao para permitir a seleção por atribut…
…os de forma complexa, com mais de um item e operador
Showing
3 changed files
with
74 additions
and
3 deletions
Show diff stats
classesphp/classe_analise.php
... | ... | @@ -2179,6 +2179,8 @@ $operacao - Tipo de análise. |
2179 | 2179 | $this->salva(); |
2180 | 2180 | $final = array(); |
2181 | 2181 | $final["layer"] = $operacao." ".(implode(" ",$lista)); |
2182 | + | |
2183 | + | |
2182 | 2184 | $final["dados"][] = array("id"=>"0","wkt"=>($calculo[0]["gwkt"]),"valores"=>$valoresoriginais,"imagem"=>($imagem["url"])); |
2183 | 2185 | $this->serializeGeo($nomegeo,$final); |
2184 | 2186 | } | ... | ... |
classesphp/classe_selecao.php
... | ... | @@ -310,9 +310,10 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa |
310 | 310 | /* |
311 | 311 | function: selecaoAtributos |
312 | 312 | |
313 | -Seleciona por atributo. | |
313 | +Seleção simples por atributo. Não permite composição de atributos. | |
314 | 314 | |
315 | 315 | parameters: |
316 | + | |
316 | 317 | $tipo - Tipo de operação adiciona|retira|inverte|limpa |
317 | 318 | |
318 | 319 | $item - Item que será consultado. |
... | ... | @@ -353,8 +354,62 @@ $valor - Valor. |
353 | 354 | {$this->layer->querybyattributes($item,'(['.$item.']'.$operador.' '.$valor.' )',1);} |
354 | 355 | } |
355 | 356 | $res_count = $this->layer->getNumresults(); |
356 | - //echo '("['.$item.']"'.$operador.'"'.$valor.'")'; | |
357 | - //echo $res_count; | |
357 | + $shpi = array(); | |
358 | + for ($i = 0; $i < $res_count; ++$i) | |
359 | + { | |
360 | + $result = $this->layer->getResult($i); | |
361 | + $shpi[] = $result->shapeindex; | |
362 | + } | |
363 | + if ($tipo == "adiciona") | |
364 | + {return($this->selecaoAdiciona($shpi,$shp_atual));} | |
365 | + if ($tipo == "retira") | |
366 | + {return($this->selecaoRetira($shpi,$shp_atual));} | |
367 | + return("ok"); | |
368 | + } | |
369 | + /* | |
370 | + function: selecaoAtributos2 | |
371 | + | |
372 | + Seleção por atributo. Permite composição de atributos. | |
373 | + | |
374 | + parameters: | |
375 | + | |
376 | + $filtro - Expressão de seleção | |
377 | + | |
378 | + $tipo - Tipo de operação adiciona|retira|inverte|limpa | |
379 | + */ | |
380 | + function selecaoAtributos2($filtro,$tipo) | |
381 | + { | |
382 | + if ($tipo == "limpa") | |
383 | + {return($this->selecaoLimpa());} | |
384 | + if ($tipo == "inverte") | |
385 | + {return($this->selecaoInverte());} | |
386 | + if(!$this->layer){return "erro";} | |
387 | + $this->layer->set("template","none.htm"); | |
388 | + $indxlayer = $this->layer->index; | |
389 | + if (file_exists(($this->arquivo)."qy")) | |
390 | + {$this->mapa->loadquery(($this->arquivo)."qy");} | |
391 | + $res_count = $this->layer->getNumresults(); | |
392 | + $shp_atual = array(); | |
393 | + for ($i = 0; $i < $res_count;++$i) | |
394 | + { | |
395 | + $rc = $this->layer->getResult($i); | |
396 | + $shp_atual[] = $rc->shapeindex; | |
397 | + } | |
398 | + $this->mapa->freequery($indxlayer); | |
399 | + $shpi = array(); | |
400 | + $items = pegaItens($this->layer); | |
401 | + $filtro = str_replace("|","'",$filtro); | |
402 | + if ($this->layer->connectiontype == MS_POSTGIS) | |
403 | + { | |
404 | + $filtro = str_replace("'[","",$filtro); | |
405 | + $filtro = str_replace("[","",$filtro); | |
406 | + $filtro = str_replace("]'","",$filtro); | |
407 | + $filtro = str_replace("]","",$filtro); | |
408 | + $filtro = str_replace("("," ",$filtro); | |
409 | + $filtro = str_replace(")"," ",$filtro); | |
410 | + } | |
411 | + $this->layer->querybyattributes($items[0],$filtro,1); | |
412 | + $res_count = $this->layer->getNumresults(); | |
358 | 413 | $shpi = array(); |
359 | 414 | for ($i = 0; $i < $res_count; ++$i) |
360 | 415 | { | ... | ... |
classesphp/mapa_controle.php
... | ... | @@ -2494,6 +2494,20 @@ Include: |
2494 | 2494 | $cp->set_data($m->selecaoAtributos($tipo,$item,$operador,$valor)); |
2495 | 2495 | break; |
2496 | 2496 | /* |
2497 | +Property: selecaoatrib2 | |
2498 | + | |
2499 | +Seleciona elementos com base nos atributos utilizando sintaxe complexa. | |
2500 | + | |
2501 | +Include: | |
2502 | +<classe_selecao.php> | |
2503 | +*/ | |
2504 | + case "selecaoatrib2": | |
2505 | + include_once("classe_selecao.php"); | |
2506 | + copiaSeguranca($map_file); | |
2507 | + $m = new Selecao($map_file,$tema); | |
2508 | + $cp->set_data($m->selecaoAtributos2($filtro,$tipo)); | |
2509 | + break; | |
2510 | +/* | |
2497 | 2511 | Property: selecaotema |
2498 | 2512 | |
2499 | 2513 | Sleciona elementos de um tema com base em outro tema. | ... | ... |