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,6 +60,18 @@ body,td { | ||
60 | </p> | 60 | </p> |
61 | </fieldset> | 61 | </fieldset> |
62 | <fieldset> | 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 | <p>Todas as opções e um tema adicionado</p> | 75 | <p>Todas as opções e um tema adicionado</p> |
64 | <p class="m"> | 76 | <p class="m"> |
65 | Windows: <a target=_blank href="openlayers.php?temas=_wbiomashp&largura=800&altura=500">openlayers.php?temas=_wbiomashp&largura=800&altura=500</a> | 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,6 +283,14 @@ if($temas != ""){ | ||
283 | if($layern->type != 2 && $layern->type != 3){ | 283 | if($layern->type != 2 && $layern->type != 3){ |
284 | $opacidade = 1; | 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 | // nesse caso o layer e adicionado como TMS | 294 | // nesse caso o layer e adicionado como TMS |
287 | // tms leva os parametros do TMS | 295 | // tms leva os parametros do TMS |
288 | $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"})'; | 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,6 +308,14 @@ if($temas != ""){ | ||
300 | if($l->type != 2 && $l->type != 3){ | 308 | if($l->type != 2 && $l->type != 3){ |
301 | $opacidade = 1; | 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 | if($tituloLayer != ""){ | 319 | if($tituloLayer != ""){ |
304 | $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.'})'; | 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,6 +370,16 @@ function ajuda(){ | ||
354 | 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 | 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 | nocache (sim) - evita o uso de imagens em cache existentes no navegador do usuário | 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 | fundo - lista com os nomes, separados por ',' dos layers que serão usados como fundo para o mapa. Se não for definido, | 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 | será usado o default. O primeiro da lista será o fundo ativo. Se na lista de temas de fundo estiver algum | 384 | será usado o default. O primeiro da lista será o fundo ativo. Se na lista de temas de fundo estiver algum |
359 | tema incluido com o parametro 'temas', esses serão incluídos como temas de fundo. | 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,6 +283,14 @@ if($temas != ""){ | ||
283 | if($layern->type != 2 && $layern->type != 3){ | 283 | if($layern->type != 2 && $layern->type != 3){ |
284 | $opacidade = 1; | 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 | // nesse caso o layer e adicionado como TMS | 294 | // nesse caso o layer e adicionado como TMS |
287 | // tms leva os parametros do TMS | 295 | // tms leva os parametros do TMS |
288 | $objOpenLayers[] = 'new OpenLayers.Layer.XYZ("'.$tituloLayer.'", "../ogc.php?Z=${z}&X=${x}&Y=${y}&'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&SRS=EPSG:3857", | 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,6 +309,14 @@ if($temas != ""){ | ||
301 | if($l->type != 2 && $l->type != 3){ | 309 | if($l->type != 2 && $l->type != 3){ |
302 | $opacidade = 1; | 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 | if($tituloLayer != ""){ | 320 | if($tituloLayer != ""){ |
305 | $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.'})'; | 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,6 +56,14 @@ id_medida_variavel - id da medida de variavel - utilizado apenas quando a fonte | ||
56 | restauramapa - ID de um mapa salvo no sistema de administracao. O mapa e restaurado e tratado como WMS | 56 | restauramapa - ID de um mapa salvo no sistema de administracao. O mapa e restaurado e tratado como WMS |
57 | 57 | ||
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 | 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 | Exemplos: | 68 | Exemplos: |
61 | 69 | ||
@@ -230,14 +238,15 @@ if(isset($_GET["Z"]) && isset($_GET["X"])){ | @@ -230,14 +238,15 @@ if(isset($_GET["Z"]) && isset($_GET["X"])){ | ||
230 | } | 238 | } |
231 | // | 239 | // |
232 | //se o outputformat for definido, evita o cahce de arquivo | 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 | $_GET["DESLIGACACHE"] = "sim"; | 244 | $_GET["DESLIGACACHE"] = "sim"; |
236 | } | 245 | } |
237 | if(isset($_GET["DESLIGACACHE"]) && $_GET["DESLIGACACHE"] == "sim"){ | 246 | if(isset($_GET["DESLIGACACHE"]) && $_GET["DESLIGACACHE"] == "sim"){ |
238 | $agora = time(); | 247 | $agora = time(); |
239 | $cache = false; | 248 | $cache = false; |
240 | -} | 249 | +} |
241 | $nomeMapfileTmp = $dir_tmp."/ogc_".md5($tema)."_".$agora.".map"; | 250 | $nomeMapfileTmp = $dir_tmp."/ogc_".md5($tema)."_".$agora.".map"; |
242 | $nomeMapfileTmp = str_replace(",","",$nomeMapfileTmp); | 251 | $nomeMapfileTmp = str_replace(",","",$nomeMapfileTmp); |
243 | $nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp); | 252 | $nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp); |
@@ -274,8 +283,7 @@ else{ | @@ -274,8 +283,7 @@ else{ | ||
274 | $oMap->setmetadata("wms_attribution_title",$tituloInstituicao); | 283 | $oMap->setmetadata("wms_attribution_title",$tituloInstituicao); |
275 | $oMap->setmetadata("ows_enable_request","*"); | 284 | $oMap->setmetadata("ows_enable_request","*"); |
276 | $e = $oMap->extent; | 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 | //gera o mapa | 287 | //gera o mapa |
280 | if ($tipo == "" || $tipo == "metadados"){ | 288 | if ($tipo == "" || $tipo == "metadados"){ |
281 | $tema = explode(" ",$tema); | 289 | $tema = explode(" ",$tema); |
@@ -395,7 +403,17 @@ else{ | @@ -395,7 +403,17 @@ else{ | ||
395 | if($versao > 5){ | 403 | if($versao > 5){ |
396 | $l->setprocessing("LABEL_NO_CLIP=True"); | 404 | $l->setprocessing("LABEL_NO_CLIP=True"); |
397 | $l->setprocessing("POLYLINE_NO_CLIP=True"); | 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 | ms_newLayerObj($oMap, $l); | 417 | ms_newLayerObj($oMap, $l); |
400 | //$req->setParameter("LAYERS", "mundo"); | 418 | //$req->setParameter("LAYERS", "mundo"); |
401 | } | 419 | } |
@@ -487,7 +505,8 @@ else{ | @@ -487,7 +505,8 @@ else{ | ||
487 | } | 505 | } |
488 | //echo "<pre>"; | 506 | //echo "<pre>"; |
489 | //var_dump($codigosTema); | 507 | //var_dump($codigosTema); |
490 | - //exit; | 508 | + //exit; |
509 | + | ||
491 | foreach($codigosTema as $c){ | 510 | foreach($codigosTema as $c){ |
492 | $codigoTema = $c["tema"]; | 511 | $codigoTema = $c["tema"]; |
493 | if(file_exists($locaplic."/temas/".$codigoTema.".map")){ | 512 | if(file_exists($locaplic."/temas/".$codigoTema.".map")){ |