Commit f515c49cc9b3539f95aba9227b64db4fdddbce54
1 parent
7608f972
Exists in
master
and in
7 other branches
Inclusão de opção para filtrar dados nos mashups.
Showing
5 changed files
with
79 additions
and
6 deletions
Show diff stats
admin/admin.db
No preview for this file type
mashups/index.html
... | ... | @@ -60,6 +60,18 @@ body,td { |
60 | 60 | </p> |
61 | 61 | </fieldset> |
62 | 62 | <fieldset> |
63 | + <p>Filtro - cada tema pode receber filtros seguindo-se a sintaxe &map_layer_{codigo do tema}_filter=<br> | |
64 | + Em camadas com origem em arquivos shapefile o valor do filtro segue o padrão (('[nome_da_coluna]'='valor_do_registro'))<br> | |
65 | + Camadas baseadas em Postgis seguem o padrão nome_da_coluna=valor_do_registro. | |
66 | + </p> | |
67 | + <p class="m"> | |
68 | + Windows: <a target=_blank href="http://localhost/i3geo/mashups/openlayers.php?map_layer__wbiomashp_filter=(('[CD_LEGENDA]'='CAATINGA'))&temas=_wbiomashp&layers=_wbiomashp">openlayers.php?map_layer__lbiomashp_filter=(('[CD_LEGENDA]'='CAATINGA'))&temas=_wbiomashp&layers=_wbiomashp</a> | |
69 | + </p> | |
70 | + <p class="m"> | |
71 | + Linux: <a target=_blank href="http://localhost/i3geo/mashups/openlayers.php?map_layer__lbiomashp_filter=(('[CD_LEGENDA]'='CAATINGA'))&temas=_lbiomashp&layers=_lbiomashp">openlayers.php?map_layer__lbiomashp_filter=(('[CD_LEGENDA]'='CAATINGA'))&temas=_lbiomashp&layers=_lbiomashp</a> | |
72 | + </p> | |
73 | + </fieldset> | |
74 | + <fieldset> | |
63 | 75 | <p>Todas as opções e um tema adicionado</p> |
64 | 76 | <p class="m"> |
65 | 77 | Windows: <a target=_blank href="openlayers.php?temas=_wbiomashp&largura=800&altura=500">openlayers.php?temas=_wbiomashp&largura=800&altura=500</a> | ... | ... |
mashups/openlayers.php
... | ... | @@ -283,6 +283,14 @@ if($temas != ""){ |
283 | 283 | if($layern->type != 2 && $layern->type != 3){ |
284 | 284 | $opacidade = 1; |
285 | 285 | } |
286 | + // | |
287 | + //verifica se deve aplicar filtro | |
288 | + // | |
289 | + $filtro = $_GET["map_layer_".$layern->name."_filter"]; | |
290 | + if(!empty($filtro)){ | |
291 | + $DESLIGACACHE = "sim"; | |
292 | + $nocache = "map_layer_".$layern->name."_filter=".$filtro."&".$nocache; | |
293 | + } | |
286 | 294 | // nesse caso o layer e adicionado como TMS |
287 | 295 | // tms leva os parametros do TMS |
288 | 296 | $objOpenLayers[] = 'new OpenLayers.Layer.TMS("'.$tituloLayer.'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'",{tileOrigin: new OpenLayers.LonLat(-180, -90),opacity:'.$opacidade.',serviceVersion:"&tms=",visibility:'.$visivel.',isBaseLayer:'.$ebase.',layername:"'.$nomeLayer.'",type:"png"})'; |
... | ... | @@ -300,6 +308,14 @@ if($temas != ""){ |
300 | 308 | if($l->type != 2 && $l->type != 3){ |
301 | 309 | $opacidade = 1; |
302 | 310 | } |
311 | + // | |
312 | + //verifica se deve aplicar filtro | |
313 | + // | |
314 | + $filtro = $_GET["map_layer_".$l->name."_filter"]; | |
315 | + if(!empty($filtro)){ | |
316 | + $DESLIGACACHE = "sim"; | |
317 | + $nocache = "map_layer_".$l->name."_filter=".$filtro."&".$nocache; | |
318 | + } | |
303 | 319 | if($tituloLayer != ""){ |
304 | 320 | $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{opacity:'.$opacidade.',layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{singleTile:true,visibility:'.$visivel.',isBaseLayer:'.$ebase.'})'; |
305 | 321 | } |
... | ... | @@ -354,6 +370,16 @@ function ajuda(){ |
354 | 370 | desligacache (sim|nao) - desativa o uso do cache de imagens em disco do lado do servidor, forçando a renderização dos tiles de cada camada em cada requisição |
355 | 371 | nocache (sim) - evita o uso de imagens em cache existentes no navegador do usuário |
356 | 372 | |
373 | + Filtros | |
374 | + | |
375 | + filtros podem ser adicionados incluindo o parametro da seguinte forma: &map_layer_<nomedotema>_filter= | |
376 | + | |
377 | + Exemplo de filtro | |
378 | + | |
379 | + ?map_layer__lbiomashp_filter=(('[CD_LEGENDA]'='CAATINGA')) | |
380 | + | |
381 | + no caso de camadas Postgis basta usar map_layer__lbiomashp_filter=cd_legenda='CAATINGA' | |
382 | + | |
357 | 383 | fundo - lista com os nomes, separados por ',' dos layers que serão usados como fundo para o mapa. Se não for definido, |
358 | 384 | será usado o default. O primeiro da lista será o fundo ativo. Se na lista de temas de fundo estiver algum |
359 | 385 | tema incluido com o parametro 'temas', esses serão incluídos como temas de fundo. | ... | ... |
mashups/osm.php
... | ... | @@ -283,6 +283,14 @@ if($temas != ""){ |
283 | 283 | if($layern->type != 2 && $layern->type != 3){ |
284 | 284 | $opacidade = 1; |
285 | 285 | } |
286 | + // | |
287 | + //verifica se deve aplicar filtro | |
288 | + // | |
289 | + $filtro = $_GET["map_layer_".$layern->name."_filter"]; | |
290 | + if(!empty($filtro)){ | |
291 | + $DESLIGACACHE = "sim"; | |
292 | + $nocache = "map_layer_".$layern->name."_filter=".$filtro."&".$nocache; | |
293 | + } | |
286 | 294 | // nesse caso o layer e adicionado como TMS |
287 | 295 | // tms leva os parametros do TMS |
288 | 296 | $objOpenLayers[] = 'new OpenLayers.Layer.XYZ("'.$tituloLayer.'", "../ogc.php?Z=${z}&X=${x}&Y=${y}&'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&SRS=EPSG:3857", |
... | ... | @@ -301,6 +309,14 @@ if($temas != ""){ |
301 | 309 | if($l->type != 2 && $l->type != 3){ |
302 | 310 | $opacidade = 1; |
303 | 311 | } |
312 | + // | |
313 | + //verifica se deve aplicar filtro | |
314 | + // | |
315 | + $filtro = $_GET["map_layer_".$l->name."_filter"]; | |
316 | + if(!empty($filtro)){ | |
317 | + $DESLIGACACHE = "sim"; | |
318 | + $nocache = "map_layer_".$l->name."_filter=".$filtro."&".$nocache; | |
319 | + } | |
304 | 320 | if($tituloLayer != ""){ |
305 | 321 | $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{opacity:'.$opacidade.',layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{singleTile:true,visibility:'.$visivel.',isBaseLayer:'.$ebase.'})'; |
306 | 322 | } | ... | ... |
ogc.php
... | ... | @@ -56,6 +56,14 @@ id_medida_variavel - id da medida de variavel - utilizado apenas quando a fonte |
56 | 56 | restauramapa - ID de um mapa salvo no sistema de administracao. O mapa e restaurado e tratado como WMS |
57 | 57 | |
58 | 58 | DESLIGACACHE (opcional) {sim|nao} - forca a nao usar o cache de imagens qd definido como "sim", do contrário, o uso ou não do cache será definido automaticamente |
59 | + | |
60 | +filtros - filtros podem ser adicionados incluindo o parametro da seguinte forma: &map_layer_<nomedotema>_filter= | |
61 | + | |
62 | + Exemplo de filtro | |
63 | + | |
64 | + http://localhost/i3geo/ogc.php?map_layer__lbiomashp_filter=(('[CD_LEGENDA]'='CAATINGA'))&tema=_lbiomashp&SRS=EPSG:4618&WIDTH=500&HEIGHT=500&BBOX=-76.5125927,-39.3925675209,-29.5851853,9.49014852081&FORMAT=image/png&service=wms&version=1.1.0&request=getmap&layers=_lbiomashp | |
65 | + | |
66 | + no caso de camadas Postgis basta usar map_layer__lbiomashp_filter=cd_legenda='CAATINGA' | |
59 | 67 | |
60 | 68 | Exemplos: |
61 | 69 | |
... | ... | @@ -230,14 +238,15 @@ if(isset($_GET["Z"]) && isset($_GET["X"])){ |
230 | 238 | } |
231 | 239 | // |
232 | 240 | //se o outputformat for definido, evita o cahce de arquivo |
241 | +//o mesmo se existir filtro para o layer | |
233 | 242 | // |
234 | -if(isset($_GET["OUTPUTFORMAT"])){ | |
243 | +if(isset($_GET["OUTPUTFORMAT"]) || !empty($_GET["map_layer_".$tema."_filter"])){ | |
235 | 244 | $_GET["DESLIGACACHE"] = "sim"; |
236 | 245 | } |
237 | 246 | if(isset($_GET["DESLIGACACHE"]) && $_GET["DESLIGACACHE"] == "sim"){ |
238 | 247 | $agora = time(); |
239 | 248 | $cache = false; |
240 | -} | |
249 | +} | |
241 | 250 | $nomeMapfileTmp = $dir_tmp."/ogc_".md5($tema)."_".$agora.".map"; |
242 | 251 | $nomeMapfileTmp = str_replace(",","",$nomeMapfileTmp); |
243 | 252 | $nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp); |
... | ... | @@ -274,8 +283,7 @@ else{ |
274 | 283 | $oMap->setmetadata("wms_attribution_title",$tituloInstituicao); |
275 | 284 | $oMap->setmetadata("ows_enable_request","*"); |
276 | 285 | $e = $oMap->extent; |
277 | - $extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); | |
278 | - | |
286 | + $extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); | |
279 | 287 | //gera o mapa |
280 | 288 | if ($tipo == "" || $tipo == "metadados"){ |
281 | 289 | $tema = explode(" ",$tema); |
... | ... | @@ -395,7 +403,17 @@ else{ |
395 | 403 | if($versao > 5){ |
396 | 404 | $l->setprocessing("LABEL_NO_CLIP=True"); |
397 | 405 | $l->setprocessing("POLYLINE_NO_CLIP=True"); |
398 | - } | |
406 | + } | |
407 | + // | |
408 | + //verifica se existem parametros de substituicao passados via url | |
409 | + // | |
410 | + $parametro = $_GET["map_layer_".$l->name."_filter"]; | |
411 | + //echo $parametro;exit; | |
412 | + if(!empty($parametro)){ | |
413 | + $l->setfilter($parametro); | |
414 | + $cache = false; | |
415 | + } | |
416 | + | |
399 | 417 | ms_newLayerObj($oMap, $l); |
400 | 418 | //$req->setParameter("LAYERS", "mundo"); |
401 | 419 | } |
... | ... | @@ -487,7 +505,8 @@ else{ |
487 | 505 | } |
488 | 506 | //echo "<pre>"; |
489 | 507 | //var_dump($codigosTema); |
490 | - //exit; | |
508 | + //exit; | |
509 | + | |
491 | 510 | foreach($codigosTema as $c){ |
492 | 511 | $codigoTema = $c["tema"]; |
493 | 512 | if(file_exists($locaplic."/temas/".$codigoTema.".map")){ | ... | ... |