Commit 5a681e41224ea73dc784364f49966bb15fa9c9b2
1 parent
012feafb
Exists in
master
and in
7 other branches
Inclusão de rotina para geração e recuperação de imagens em cache em ogc.php e mashup openlayers
Showing
7 changed files
with
208 additions
and
101 deletions
Show diff stats
admin/admin.db
No preview for this file type
classesphp/mapa_openlayers.php
| @@ -334,28 +334,6 @@ function carregaCacheImagem($cachedir,$map,$tms){ | @@ -334,28 +334,6 @@ function carregaCacheImagem($cachedir,$map,$tms){ | ||
| 334 | exit; | 334 | exit; |
| 335 | } | 335 | } |
| 336 | } | 336 | } |
| 337 | -function XcarregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ | ||
| 338 | - if($layer == "copyright" || $layer == "") | ||
| 339 | - {$bbox = "";} | ||
| 340 | - if($layer == "") | ||
| 341 | - {$layer = "fundo";} | ||
| 342 | - $nome = $w.$h.$bbox.".png"; | ||
| 343 | - if($cachedir == "") | ||
| 344 | - {$nome = dirname(dirname($map))."/cache/".$layer."/".$nome;} | ||
| 345 | - else | ||
| 346 | - {$nome = $cachedir."/".$layer."/".$nome;} | ||
| 347 | - if(file_exists($nome)){ | ||
| 348 | - header('Content-Length: '.filesize($nome)); | ||
| 349 | - header('Content-Type: image/png'); | ||
| 350 | - header('Cache-Control: max-age=3600, must-revalidate'); | ||
| 351 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | ||
| 352 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); | ||
| 353 | - $etag = md5_file($nome); | ||
| 354 | - header('Etag: '.$etag); | ||
| 355 | - fpassthru(fopen($nome, 'rb')); | ||
| 356 | - exit; | ||
| 357 | - } | ||
| 358 | -} | ||
| 359 | function nomeRand($n=10) | 337 | function nomeRand($n=10) |
| 360 | { | 338 | { |
| 361 | $nomes = ""; | 339 | $nomes = ""; |
mashups/openlayers.js
| @@ -204,7 +204,7 @@ i3GEO.editorOL = { | @@ -204,7 +204,7 @@ i3GEO.editorOL = { | ||
| 204 | {i3GEO.editorOL.ativaLayerSwitcher();} | 204 | {i3GEO.editorOL.ativaLayerSwitcher();} |
| 205 | if(i3GEO.editorOL.ativarodadomouse === false) | 205 | if(i3GEO.editorOL.ativarodadomouse === false) |
| 206 | {i3GEO.editorOL.desativaRodaDoMouse();} | 206 | {i3GEO.editorOL.desativaRodaDoMouse();} |
| 207 | - | 207 | + |
| 208 | if(i3GEO.editorOL.numzoom !== ""){ | 208 | if(i3GEO.editorOL.numzoom !== ""){ |
| 209 | i3GEO.editorOL.mapa.setOptions({ | 209 | i3GEO.editorOL.mapa.setOptions({ |
| 210 | numZoomLevels: i3GEO.editorOL.numzoom | 210 | numZoomLevels: i3GEO.editorOL.numzoom |
| @@ -277,6 +277,17 @@ i3GEO.editorOL = { | @@ -277,6 +277,17 @@ i3GEO.editorOL = { | ||
| 277 | } | 277 | } |
| 278 | return ins; | 278 | return ins; |
| 279 | }, | 279 | }, |
| 280 | + layersClonados: function(paramsLayers){ | ||
| 281 | + var layers = i3GEO.editorOL.mapa.layers, | ||
| 282 | + nlayers = layers.length, | ||
| 283 | + ins = [],i; | ||
| 284 | + for(i=0;i<nlayers;i++){ | ||
| 285 | + if(layers[i].params.CLONETMS === paramsLayers){ | ||
| 286 | + return(layers[i]); | ||
| 287 | + } | ||
| 288 | + } | ||
| 289 | + return false; | ||
| 290 | + }, | ||
| 280 | coordenadas: function(){ | 291 | coordenadas: function(){ |
| 281 | // | 292 | // |
| 282 | //substitui o controle que mostra as coordenadas | 293 | //substitui o controle que mostra as coordenadas |
| @@ -702,7 +713,7 @@ i3GEO.editorOL = { | @@ -702,7 +713,7 @@ i3GEO.editorOL = { | ||
| 702 | button = new OpenLayers.Control.Button({ | 713 | button = new OpenLayers.Control.Button({ |
| 703 | displayClass: "editorOLzoomtot", | 714 | displayClass: "editorOLzoomtot", |
| 704 | trigger: function(){i3GEO.editorOL.mapa.zoomToMaxExtent();}, | 715 | trigger: function(){i3GEO.editorOL.mapa.zoomToMaxExtent();}, |
| 705 | - title: "ajusta extensão", | 716 | + title: "ajusta extensao", |
| 706 | type: OpenLayers.Control.TYPE_BUTTON | 717 | type: OpenLayers.Control.TYPE_BUTTON |
| 707 | }); | 718 | }); |
| 708 | controles.push(button); | 719 | controles.push(button); |
| @@ -725,7 +736,7 @@ i3GEO.editorOL = { | @@ -725,7 +736,7 @@ i3GEO.editorOL = { | ||
| 725 | handlerOptions: {layerOptions: {styleMap: styleMap}}, | 736 | handlerOptions: {layerOptions: {styleMap: styleMap}}, |
| 726 | persist: true, | 737 | persist: true, |
| 727 | displayClass: "editorOLdistancia", | 738 | displayClass: "editorOLdistancia", |
| 728 | - title: "distância", | 739 | + title: "distancia", |
| 729 | type: OpenLayers.Control.TYPE_TOOL | 740 | type: OpenLayers.Control.TYPE_TOOL |
| 730 | } | 741 | } |
| 731 | ); | 742 | ); |
| @@ -746,7 +757,7 @@ i3GEO.editorOL = { | @@ -746,7 +757,7 @@ i3GEO.editorOL = { | ||
| 746 | handlerOptions: {layerOptions: {styleMap: styleMap}}, | 757 | handlerOptions: {layerOptions: {styleMap: styleMap}}, |
| 747 | persist: true, | 758 | persist: true, |
| 748 | displayClass: "editorOLarea", | 759 | displayClass: "editorOLarea", |
| 749 | - title: "área", | 760 | + title: "area", |
| 750 | type: OpenLayers.Control.TYPE_TOOL | 761 | type: OpenLayers.Control.TYPE_TOOL |
| 751 | } | 762 | } |
| 752 | ); | 763 | ); |
| @@ -771,6 +782,14 @@ i3GEO.editorOL = { | @@ -771,6 +782,14 @@ i3GEO.editorOL = { | ||
| 771 | displayClass: "editorOLidentifica", | 782 | displayClass: "editorOLidentifica", |
| 772 | eventListeners: { | 783 | eventListeners: { |
| 773 | getfeatureinfo: function(event) { | 784 | getfeatureinfo: function(event) { |
| 785 | + var ativo = [i3GEO.editorOL.layerAtivo()]; | ||
| 786 | + //se for TMS tem de pegar o clone wms | ||
| 787 | + if(ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS"){ | ||
| 788 | + temp = i3GEO.editorOL.layersClonados(ativo[0].layername); | ||
| 789 | + if(temp != ""){ | ||
| 790 | + temp.setVisibility(false); | ||
| 791 | + } | ||
| 792 | + } | ||
| 774 | var lonlat = i3GEO.editorOL.mapa.getLonLatFromPixel(event.xy), | 793 | var lonlat = i3GEO.editorOL.mapa.getLonLatFromPixel(event.xy), |
| 775 | lonlattexto = "<hr>", | 794 | lonlattexto = "<hr>", |
| 776 | formata; | 795 | formata; |
| @@ -815,7 +834,15 @@ i3GEO.editorOL = { | @@ -815,7 +834,15 @@ i3GEO.editorOL = { | ||
| 815 | )); | 834 | )); |
| 816 | }, | 835 | }, |
| 817 | beforegetfeatureinfo: function(event){ | 836 | beforegetfeatureinfo: function(event){ |
| 818 | - var ativo = [i3GEO.editorOL.layerAtivo()]; | 837 | + var temp,ativo = [i3GEO.editorOL.layerAtivo()]; |
| 838 | + //se for TMS tem de pegar o clone wms | ||
| 839 | + if(ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS"){ | ||
| 840 | + temp = i3GEO.editorOL.layersClonados(ativo[0].layername); | ||
| 841 | + if(temp != ""){ | ||
| 842 | + temp.setVisibility(true); | ||
| 843 | + ativo = [temp]; | ||
| 844 | + } | ||
| 845 | + } | ||
| 819 | event.object.layers = ativo; | 846 | event.object.layers = ativo; |
| 820 | botaoIdentifica.layers = ativo; | 847 | botaoIdentifica.layers = ativo; |
| 821 | botaoIdentifica.url = ativo[0].url; | 848 | botaoIdentifica.url = ativo[0].url; |
| @@ -895,7 +922,7 @@ i3GEO.editorOL = { | @@ -895,7 +922,7 @@ i3GEO.editorOL = { | ||
| 895 | OpenLayers.Handler.Polygon, | 922 | OpenLayers.Handler.Polygon, |
| 896 | { | 923 | { |
| 897 | displayClass: "editorOLpoligono", | 924 | displayClass: "editorOLpoligono", |
| 898 | - title: "digitalizar polígono", | 925 | + title: "digitalizar poligono", |
| 899 | type: OpenLayers.Control.TYPE_TOOL, | 926 | type: OpenLayers.Control.TYPE_TOOL, |
| 900 | //handlerOptions: {holeModifier: "altKey"}, | 927 | //handlerOptions: {holeModifier: "altKey"}, |
| 901 | callbacks:{ | 928 | callbacks:{ |
mashups/openlayers.php
| @@ -140,7 +140,6 @@ if(isset($fundo) && $fundo != ""){ | @@ -140,7 +140,6 @@ if(isset($fundo) && $fundo != ""){ | ||
| 140 | $fundo = str_replace(","," ",$fundo); | 140 | $fundo = str_replace(","," ",$fundo); |
| 141 | $fundo = explode(" ",$fundo); | 141 | $fundo = explode(" ",$fundo); |
| 142 | } | 142 | } |
| 143 | - | ||
| 144 | // | 143 | // |
| 145 | //define quais os layers que comporão o mapa | 144 | //define quais os layers que comporão o mapa |
| 146 | // | 145 | // |
| @@ -189,7 +188,8 @@ if($temas != ""){ | @@ -189,7 +188,8 @@ if($temas != ""){ | ||
| 189 | $layers = array(); | 188 | $layers = array(); |
| 190 | $maptemp = @ms_newMapObj($nomeMap); | 189 | $maptemp = @ms_newMapObj($nomeMap); |
| 191 | if($maptemp){ | 190 | if($maptemp){ |
| 192 | - for($i=0;$i<($maptemp->numlayers);++$i) { | 191 | + $nlayers = $maptemp->numlayers; |
| 192 | + for($i=0;$i<($nlayers);++$i) { | ||
| 193 | $layern = $maptemp->getLayer($i); | 193 | $layern = $maptemp->getLayer($i); |
| 194 | $layers[] = $layern->name; | 194 | $layers[] = $layern->name; |
| 195 | } | 195 | } |
| @@ -204,7 +204,17 @@ if($temas != ""){ | @@ -204,7 +204,17 @@ if($temas != ""){ | ||
| 204 | $visivel = "false"; | 204 | $visivel = "false"; |
| 205 | if(in_array($tema,$visiveis)) | 205 | if(in_array($tema,$visiveis)) |
| 206 | {$visivel = "true";} | 206 | {$visivel = "true";} |
| 207 | - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?tema='.$tema.'&",{layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{singleTile:true,visibility:'.$visivel.',isBaseLayer:'.$ebase.'})'; | 207 | + if($nlayers == 1 && strtoupper($layern->getmetadata("cache")) == "SIM"){ |
| 208 | + //nesse caso o layer e adicionado como TMS | ||
| 209 | + //tms leva os parametros do TMS | ||
| 210 | + $objOpenLayers[] = 'new OpenLayers.Layer.TMS("'.$tituloLayer.'", "../ogc.php?tema='.$tema.'",{tileOrigin: new OpenLayers.LonLat(-180, -90),serviceVersion:"&tms=",visibility:'.$visivel.',isBaseLayer:'.$ebase.',layername:"'.$nomeLayer.'",type:"png"})'; | ||
| 211 | + //cria um clone WMS para efeitos de getfeatureinfo | ||
| 212 | + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?tema='.$tema.'&",{cloneTMS:"'.$nomeLayer.'",layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{displayInLayerSwitcher:false,singleTile:true,visibility:false,isBaseLayer:false})'; | ||
| 213 | + } | ||
| 214 | + else{ | ||
| 215 | + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?tema='.$tema.'&",{layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{singleTile:true,visibility:'.$visivel.',isBaseLayer:'.$ebase.'})'; | ||
| 216 | + } | ||
| 217 | + //var_dump($objOpenLayers);exit; | ||
| 208 | } | 218 | } |
| 209 | } | 219 | } |
| 210 | else | 220 | else |
| @@ -313,18 +323,19 @@ Par&acirc;metros: | @@ -313,18 +323,19 @@ Par&acirc;metros: | ||
| 313 | <script type="text/javascript" src="../pacotes/yui290/build/dragdrop/dragdrop-min.js"></script> | 323 | <script type="text/javascript" src="../pacotes/yui290/build/dragdrop/dragdrop-min.js"></script> |
| 314 | <script type="text/javascript" src="../pacotes/yui290/build/container/container-min.js"></script> | 324 | <script type="text/javascript" src="../pacotes/yui290/build/container/container-min.js"></script> |
| 315 | <script type="text/javascript" src="../classesjs/compactados/classe_calculo_compacto.js"></script> | 325 | <script type="text/javascript" src="../classesjs/compactados/classe_calculo_compacto.js"></script> |
| 326 | +<script type="text/javascript" src="../classesjs/compactados/classe_util_compacto.js"></script> | ||
| 316 | <script type="text/javascript" src="../pacotes/openlayers/OpenLayers211.js"></script> | 327 | <script type="text/javascript" src="../pacotes/openlayers/OpenLayers211.js"></script> |
| 317 | <script type="text/javascript" src="openlayers.js"></script> | 328 | <script type="text/javascript" src="openlayers.js"></script> |
| 318 | - | 329 | +<link rel="stylesheet" href="theme/default/style.css" type="text/css" /> |
| 330 | +<link rel="stylesheet" href="openlayers.css" type="text/css" /> | ||
| 319 | --> | 331 | --> |
| 332 | + | ||
| 333 | + | ||
| 320 | <script type="text/javascript" src="openlayers_compacto.js.php"></script> | 334 | <script type="text/javascript" src="openlayers_compacto.js.php"></script> |
| 321 | <script type="text/javascript" src="../classesjs/compactados/classe_util_compacto.js"></script> | 335 | <script type="text/javascript" src="../classesjs/compactados/classe_util_compacto.js"></script> |
| 322 | <link rel="stylesheet" href="openlayers_compacto.css" type="text/css" /> | 336 | <link rel="stylesheet" href="openlayers_compacto.css" type="text/css" /> |
| 323 | 337 | ||
| 324 | -<!-- | ||
| 325 | -<link rel="stylesheet" href="theme/default/style.css" type="text/css" /> | ||
| 326 | -<link rel="stylesheet" href="openlayers.css" type="text/css" /> | ||
| 327 | ---> | 338 | + |
| 328 | <style> | 339 | <style> |
| 329 | .yui-skin-sam .container-minimiza { | 340 | .yui-skin-sam .container-minimiza { |
| 330 | background:transparent url(../pacotes/yui290/build/assets/skins/sam/sprite.png) no-repeat scroll 0 -450px; | 341 | background:transparent url(../pacotes/yui290/build/assets/skins/sam/sprite.png) no-repeat scroll 0 -450px; |
| @@ -433,7 +444,7 @@ i3GEO.editorOL.mapa = new OpenLayers.Map( | @@ -433,7 +444,7 @@ i3GEO.editorOL.mapa = new OpenLayers.Map( | ||
| 433 | 'i3geoMapa', | 444 | 'i3geoMapa', |
| 434 | { | 445 | { |
| 435 | controls:[], | 446 | controls:[], |
| 436 | - resolutions:[0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125,0.000021457672119140625] | 447 | + resolutions: [0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125,0.000021457672119140625,0.000010728836059570312,0.000005364418029785156,0.000002682209014892578] |
| 437 | } | 448 | } |
| 438 | ); | 449 | ); |
| 439 | i3GEO.editorOL.inicia(); | 450 | i3GEO.editorOL.inicia(); |
mashups/openlayers_compacto.js
| @@ -3290,6 +3290,17 @@ ins.push(layers[i]); | @@ -3290,6 +3290,17 @@ ins.push(layers[i]); | ||
| 3290 | } | 3290 | } |
| 3291 | return ins; | 3291 | return ins; |
| 3292 | }, | 3292 | }, |
| 3293 | +layersClonados: function(paramsLayers){ | ||
| 3294 | +var layers = i3GEO.editorOL.mapa.layers, | ||
| 3295 | +nlayers = layers.length, | ||
| 3296 | +ins = [],i; | ||
| 3297 | +for(i=0;i<nlayers;i++){ | ||
| 3298 | +if(layers[i].params.CLONETMS === paramsLayers){ | ||
| 3299 | +return(layers[i]); | ||
| 3300 | +} | ||
| 3301 | +} | ||
| 3302 | +return false; | ||
| 3303 | +}, | ||
| 3293 | coordenadas: function(){ | 3304 | coordenadas: function(){ |
| 3294 | // | 3305 | // |
| 3295 | //substitui o controle que mostra as coordenadas | 3306 | //substitui o controle que mostra as coordenadas |
| @@ -3710,7 +3721,7 @@ if(botoes.zoomtot===true){ | @@ -3710,7 +3721,7 @@ if(botoes.zoomtot===true){ | ||
| 3710 | button = new OpenLayers.Control.Button({ | 3721 | button = new OpenLayers.Control.Button({ |
| 3711 | displayClass: "editorOLzoomtot", | 3722 | displayClass: "editorOLzoomtot", |
| 3712 | trigger: function(){i3GEO.editorOL.mapa.zoomToMaxExtent();}, | 3723 | trigger: function(){i3GEO.editorOL.mapa.zoomToMaxExtent();}, |
| 3713 | -title: "ajusta extensão", | 3724 | +title: "ajusta extensao", |
| 3714 | type: OpenLayers.Control.TYPE_BUTTON | 3725 | type: OpenLayers.Control.TYPE_BUTTON |
| 3715 | }); | 3726 | }); |
| 3716 | controles.push(button); | 3727 | controles.push(button); |
| @@ -3733,7 +3744,7 @@ OpenLayers.Handler.Path, | @@ -3733,7 +3744,7 @@ OpenLayers.Handler.Path, | ||
| 3733 | handlerOptions: {layerOptions: {styleMap: styleMap}}, | 3744 | handlerOptions: {layerOptions: {styleMap: styleMap}}, |
| 3734 | persist: true, | 3745 | persist: true, |
| 3735 | displayClass: "editorOLdistancia", | 3746 | displayClass: "editorOLdistancia", |
| 3736 | -title: "distância", | 3747 | +title: "distancia", |
| 3737 | type: OpenLayers.Control.TYPE_TOOL | 3748 | type: OpenLayers.Control.TYPE_TOOL |
| 3738 | } | 3749 | } |
| 3739 | ); | 3750 | ); |
| @@ -3754,7 +3765,7 @@ OpenLayers.Handler.Polygon, | @@ -3754,7 +3765,7 @@ OpenLayers.Handler.Polygon, | ||
| 3754 | handlerOptions: {layerOptions: {styleMap: styleMap}}, | 3765 | handlerOptions: {layerOptions: {styleMap: styleMap}}, |
| 3755 | persist: true, | 3766 | persist: true, |
| 3756 | displayClass: "editorOLarea", | 3767 | displayClass: "editorOLarea", |
| 3757 | -title: "área", | 3768 | +title: "area", |
| 3758 | type: OpenLayers.Control.TYPE_TOOL | 3769 | type: OpenLayers.Control.TYPE_TOOL |
| 3759 | } | 3770 | } |
| 3760 | ); | 3771 | ); |
| @@ -3779,6 +3790,14 @@ type: OpenLayers.Control.TYPE_TOOL, | @@ -3779,6 +3790,14 @@ type: OpenLayers.Control.TYPE_TOOL, | ||
| 3779 | displayClass: "editorOLidentifica", | 3790 | displayClass: "editorOLidentifica", |
| 3780 | eventListeners: { | 3791 | eventListeners: { |
| 3781 | getfeatureinfo: function(event) { | 3792 | getfeatureinfo: function(event) { |
| 3793 | +var ativo = [i3GEO.editorOL.layerAtivo()]; | ||
| 3794 | +//se for TMS tem de pegar o clone wms | ||
| 3795 | +if(ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS"){ | ||
| 3796 | +temp = i3GEO.editorOL.layersClonados(ativo[0].layername); | ||
| 3797 | +if(temp != ""){ | ||
| 3798 | +temp.setVisibility(false); | ||
| 3799 | +} | ||
| 3800 | +} | ||
| 3782 | var lonlat = i3GEO.editorOL.mapa.getLonLatFromPixel(event.xy), | 3801 | var lonlat = i3GEO.editorOL.mapa.getLonLatFromPixel(event.xy), |
| 3783 | lonlattexto = "<hr>", | 3802 | lonlattexto = "<hr>", |
| 3784 | formata; | 3803 | formata; |
| @@ -3823,7 +3842,15 @@ true | @@ -3823,7 +3842,15 @@ true | ||
| 3823 | )); | 3842 | )); |
| 3824 | }, | 3843 | }, |
| 3825 | beforegetfeatureinfo: function(event){ | 3844 | beforegetfeatureinfo: function(event){ |
| 3826 | -var ativo = [i3GEO.editorOL.layerAtivo()]; | 3845 | +var temp,ativo = [i3GEO.editorOL.layerAtivo()]; |
| 3846 | +//se for TMS tem de pegar o clone wms | ||
| 3847 | +if(ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS"){ | ||
| 3848 | +temp = i3GEO.editorOL.layersClonados(ativo[0].layername); | ||
| 3849 | +if(temp != ""){ | ||
| 3850 | +temp.setVisibility(true); | ||
| 3851 | +ativo = [temp]; | ||
| 3852 | +} | ||
| 3853 | +} | ||
| 3827 | event.object.layers = ativo; | 3854 | event.object.layers = ativo; |
| 3828 | botaoIdentifica.layers = ativo; | 3855 | botaoIdentifica.layers = ativo; |
| 3829 | botaoIdentifica.url = ativo[0].url; | 3856 | botaoIdentifica.url = ativo[0].url; |
| @@ -3903,7 +3930,7 @@ i3GEO.editorOL.layergrafico, | @@ -3903,7 +3930,7 @@ i3GEO.editorOL.layergrafico, | ||
| 3903 | OpenLayers.Handler.Polygon, | 3930 | OpenLayers.Handler.Polygon, |
| 3904 | { | 3931 | { |
| 3905 | displayClass: "editorOLpoligono", | 3932 | displayClass: "editorOLpoligono", |
| 3906 | -title: "digitalizar polígono", | 3933 | +title: "digitalizar poligono", |
| 3907 | type: OpenLayers.Control.TYPE_TOOL, | 3934 | type: OpenLayers.Control.TYPE_TOOL, |
| 3908 | //handlerOptions: {holeModifier: "altKey"}, | 3935 | //handlerOptions: {holeModifier: "altKey"}, |
| 3909 | callbacks:{ | 3936 | callbacks:{ |
mashups/openlayers_compacto.js.php
| @@ -3290,6 +3290,17 @@ ins.push(layers[i]); | @@ -3290,6 +3290,17 @@ ins.push(layers[i]); | ||
| 3290 | } | 3290 | } |
| 3291 | return ins; | 3291 | return ins; |
| 3292 | }, | 3292 | }, |
| 3293 | +layersClonados: function(paramsLayers){ | ||
| 3294 | +var layers = i3GEO.editorOL.mapa.layers, | ||
| 3295 | +nlayers = layers.length, | ||
| 3296 | +ins = [],i; | ||
| 3297 | +for(i=0;i<nlayers;i++){ | ||
| 3298 | +if(layers[i].params.CLONETMS === paramsLayers){ | ||
| 3299 | +return(layers[i]); | ||
| 3300 | +} | ||
| 3301 | +} | ||
| 3302 | +return false; | ||
| 3303 | +}, | ||
| 3293 | coordenadas: function(){ | 3304 | coordenadas: function(){ |
| 3294 | // | 3305 | // |
| 3295 | //substitui o controle que mostra as coordenadas | 3306 | //substitui o controle que mostra as coordenadas |
| @@ -3710,7 +3721,7 @@ if(botoes.zoomtot===true){ | @@ -3710,7 +3721,7 @@ if(botoes.zoomtot===true){ | ||
| 3710 | button = new OpenLayers.Control.Button({ | 3721 | button = new OpenLayers.Control.Button({ |
| 3711 | displayClass: "editorOLzoomtot", | 3722 | displayClass: "editorOLzoomtot", |
| 3712 | trigger: function(){i3GEO.editorOL.mapa.zoomToMaxExtent();}, | 3723 | trigger: function(){i3GEO.editorOL.mapa.zoomToMaxExtent();}, |
| 3713 | -title: "ajusta extensão", | 3724 | +title: "ajusta extensao", |
| 3714 | type: OpenLayers.Control.TYPE_BUTTON | 3725 | type: OpenLayers.Control.TYPE_BUTTON |
| 3715 | }); | 3726 | }); |
| 3716 | controles.push(button); | 3727 | controles.push(button); |
| @@ -3733,7 +3744,7 @@ OpenLayers.Handler.Path, | @@ -3733,7 +3744,7 @@ OpenLayers.Handler.Path, | ||
| 3733 | handlerOptions: {layerOptions: {styleMap: styleMap}}, | 3744 | handlerOptions: {layerOptions: {styleMap: styleMap}}, |
| 3734 | persist: true, | 3745 | persist: true, |
| 3735 | displayClass: "editorOLdistancia", | 3746 | displayClass: "editorOLdistancia", |
| 3736 | -title: "distância", | 3747 | +title: "distancia", |
| 3737 | type: OpenLayers.Control.TYPE_TOOL | 3748 | type: OpenLayers.Control.TYPE_TOOL |
| 3738 | } | 3749 | } |
| 3739 | ); | 3750 | ); |
| @@ -3754,7 +3765,7 @@ OpenLayers.Handler.Polygon, | @@ -3754,7 +3765,7 @@ OpenLayers.Handler.Polygon, | ||
| 3754 | handlerOptions: {layerOptions: {styleMap: styleMap}}, | 3765 | handlerOptions: {layerOptions: {styleMap: styleMap}}, |
| 3755 | persist: true, | 3766 | persist: true, |
| 3756 | displayClass: "editorOLarea", | 3767 | displayClass: "editorOLarea", |
| 3757 | -title: "área", | 3768 | +title: "area", |
| 3758 | type: OpenLayers.Control.TYPE_TOOL | 3769 | type: OpenLayers.Control.TYPE_TOOL |
| 3759 | } | 3770 | } |
| 3760 | ); | 3771 | ); |
| @@ -3779,6 +3790,14 @@ type: OpenLayers.Control.TYPE_TOOL, | @@ -3779,6 +3790,14 @@ type: OpenLayers.Control.TYPE_TOOL, | ||
| 3779 | displayClass: "editorOLidentifica", | 3790 | displayClass: "editorOLidentifica", |
| 3780 | eventListeners: { | 3791 | eventListeners: { |
| 3781 | getfeatureinfo: function(event) { | 3792 | getfeatureinfo: function(event) { |
| 3793 | +var ativo = [i3GEO.editorOL.layerAtivo()]; | ||
| 3794 | +//se for TMS tem de pegar o clone wms | ||
| 3795 | +if(ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS"){ | ||
| 3796 | +temp = i3GEO.editorOL.layersClonados(ativo[0].layername); | ||
| 3797 | +if(temp != ""){ | ||
| 3798 | +temp.setVisibility(false); | ||
| 3799 | +} | ||
| 3800 | +} | ||
| 3782 | var lonlat = i3GEO.editorOL.mapa.getLonLatFromPixel(event.xy), | 3801 | var lonlat = i3GEO.editorOL.mapa.getLonLatFromPixel(event.xy), |
| 3783 | lonlattexto = "<hr>", | 3802 | lonlattexto = "<hr>", |
| 3784 | formata; | 3803 | formata; |
| @@ -3823,7 +3842,15 @@ true | @@ -3823,7 +3842,15 @@ true | ||
| 3823 | )); | 3842 | )); |
| 3824 | }, | 3843 | }, |
| 3825 | beforegetfeatureinfo: function(event){ | 3844 | beforegetfeatureinfo: function(event){ |
| 3826 | -var ativo = [i3GEO.editorOL.layerAtivo()]; | 3845 | +var temp,ativo = [i3GEO.editorOL.layerAtivo()]; |
| 3846 | +//se for TMS tem de pegar o clone wms | ||
| 3847 | +if(ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS"){ | ||
| 3848 | +temp = i3GEO.editorOL.layersClonados(ativo[0].layername); | ||
| 3849 | +if(temp != ""){ | ||
| 3850 | +temp.setVisibility(true); | ||
| 3851 | +ativo = [temp]; | ||
| 3852 | +} | ||
| 3853 | +} | ||
| 3827 | event.object.layers = ativo; | 3854 | event.object.layers = ativo; |
| 3828 | botaoIdentifica.layers = ativo; | 3855 | botaoIdentifica.layers = ativo; |
| 3829 | botaoIdentifica.url = ativo[0].url; | 3856 | botaoIdentifica.url = ativo[0].url; |
| @@ -3903,7 +3930,7 @@ i3GEO.editorOL.layergrafico, | @@ -3903,7 +3930,7 @@ i3GEO.editorOL.layergrafico, | ||
| 3903 | OpenLayers.Handler.Polygon, | 3930 | OpenLayers.Handler.Polygon, |
| 3904 | { | 3931 | { |
| 3905 | displayClass: "editorOLpoligono", | 3932 | displayClass: "editorOLpoligono", |
| 3906 | -title: "digitalizar polígono", | 3933 | +title: "digitalizar poligono", |
| 3907 | type: OpenLayers.Control.TYPE_TOOL, | 3934 | type: OpenLayers.Control.TYPE_TOOL, |
| 3908 | //handlerOptions: {holeModifier: "altKey"}, | 3935 | //handlerOptions: {holeModifier: "altKey"}, |
| 3909 | callbacks:{ | 3936 | callbacks:{ |
ogc.php
| @@ -120,7 +120,7 @@ include(dirname(__FILE__)."/classesphp/funcoes_gerais.php"); | @@ -120,7 +120,7 @@ include(dirname(__FILE__)."/classesphp/funcoes_gerais.php"); | ||
| 120 | error_reporting(0); | 120 | error_reporting(0); |
| 121 | $versao = versao(); | 121 | $versao = versao(); |
| 122 | $versao = $versao["principal"]; | 122 | $versao = $versao["principal"]; |
| 123 | -$req = ms_newowsrequestobj(); | 123 | +$req = ms_newowsrequestobj(); |
| 124 | $tipo = ""; | 124 | $tipo = ""; |
| 125 | $_GET = array_merge($_GET,$_POST); | 125 | $_GET = array_merge($_GET,$_POST); |
| 126 | if(isset($_GET["sld"]) || isset($_GET["filter"])){ | 126 | if(isset($_GET["sld"]) || isset($_GET["filter"])){ |
| @@ -135,12 +135,10 @@ foreach ($_GET as $k=>$v){ | @@ -135,12 +135,10 @@ foreach ($_GET as $k=>$v){ | ||
| 135 | $tipo = "metadados"; | 135 | $tipo = "metadados"; |
| 136 | $cache = false; | 136 | $cache = false; |
| 137 | } | 137 | } |
| 138 | - if(strtolower($k) == "layers" && empty($_GET["tema"])) | ||
| 139 | - { | 138 | + if(strtolower($k) == "layers" && empty($_GET["tema"])){ |
| 140 | $tema = $v; | 139 | $tema = $v; |
| 141 | } | 140 | } |
| 142 | - if(strtolower($k) == "layer" && empty($_GET["tema"])) | ||
| 143 | - { | 141 | + if(strtolower($k) == "layer" && empty($_GET["tema"])){ |
| 144 | $tema = $v; | 142 | $tema = $v; |
| 145 | } | 143 | } |
| 146 | } | 144 | } |
| @@ -162,17 +160,6 @@ if(isset($version) && !isset($VERSION)){ | @@ -162,17 +160,6 @@ if(isset($version) && !isset($VERSION)){ | ||
| 162 | if(!isset($VERSION)){ | 160 | if(!isset($VERSION)){ |
| 163 | $req->setParameter("VeRsIoN","1.0.0"); | 161 | $req->setParameter("VeRsIoN","1.0.0"); |
| 164 | } | 162 | } |
| 165 | -/* | ||
| 166 | -$n = $req->numparams; | ||
| 167 | -for($i=0;$i<$n;$i++){ | ||
| 168 | - echo $req->getName($i); | ||
| 169 | - echo "="; | ||
| 170 | - echo $req->getValue($i); | ||
| 171 | - echo "<br>"; | ||
| 172 | -} | ||
| 173 | -exit; | ||
| 174 | -*/ | ||
| 175 | - | ||
| 176 | if (!isset($intervalo)){ | 163 | if (!isset($intervalo)){ |
| 177 | $intervalo = "0,5000"; | 164 | $intervalo = "0,5000"; |
| 178 | } | 165 | } |
| @@ -190,7 +177,6 @@ if(!isset($tema)){ | @@ -190,7 +177,6 @@ if(!isset($tema)){ | ||
| 190 | $nomeMapfileTmp = $dir_tmp."/ogc_".md5($tema).".map"; | 177 | $nomeMapfileTmp = $dir_tmp."/ogc_".md5($tema).".map"; |
| 191 | $nomeMapfileTmp = str_replace(",","",$nomeMapfileTmp); | 178 | $nomeMapfileTmp = str_replace(",","",$nomeMapfileTmp); |
| 192 | $nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp); | 179 | $nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp); |
| 193 | - | ||
| 194 | if(file_exists($nomeMapfileTmp) && $tipo == ""){ | 180 | if(file_exists($nomeMapfileTmp) && $tipo == ""){ |
| 195 | $oMap = ms_newMapobj($nomeMapfileTmp); | 181 | $oMap = ms_newMapobj($nomeMapfileTmp); |
| 196 | } | 182 | } |
| @@ -461,21 +447,63 @@ else{ | @@ -461,21 +447,63 @@ else{ | ||
| 461 | $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename)); | 447 | $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename)); |
| 462 | $oMap->save($nomeMapfileTmp); | 448 | $oMap->save($nomeMapfileTmp); |
| 463 | } | 449 | } |
| 464 | -if($cache == true){ | ||
| 465 | - | 450 | +// |
| 451 | +//verifica se a requisicao e do tipo TMS. Se for, tenta gerar ou usar o cache | ||
| 452 | +// | ||
| 453 | +// | ||
| 454 | +//calcula a extensao geografica com base no x,y,z em requisições TMS | ||
| 455 | +//quando for do tipo tms $_GET["tms"] contem os parametros do tile | ||
| 456 | +//essa rotina faz um exit ao final | ||
| 457 | +//o cache tms so fucniona se houver apenas uma camada no mapa | ||
| 458 | +//tms e usado basicamente por mashup | ||
| 459 | +// | ||
| 460 | +if(isset($_GET["tms"])){ | ||
| 461 | + $temp = explode("/",$_GET["tms"]); | ||
| 462 | + $z = $temp[2]; | ||
| 463 | + $x = $temp[3]; | ||
| 464 | + $y = str_replace(".png","",$temp[4]); | ||
| 465 | + $n = pow(2,$z+1); | ||
| 466 | + $lon1 = $x / $n * 360.0 - 180.0; | ||
| 467 | + $lon2 = ($x+1) / $n * 360.0 - 180.0; | ||
| 468 | + $n = pow(2,$z); | ||
| 469 | + $lat1 = $y / $n * 180.0 - 90.0; | ||
| 470 | + $lat2 = ($y+1) / $n * 180.0 - 90.0; | ||
| 471 | + //essa funcao termina o processo se a imagem existir | ||
| 472 | + //carregaCacheImagem($cachedir,$nomeMapfileTmp,$_GET["tms"]); | ||
| 473 | + //se nao existir, salva a imagem | ||
| 474 | + //echo $lon1." ".$lat1." ".$lon2." ".$lat2;exit; | ||
| 475 | + $oMap->setExtent($lon1,$lat1,$lon2,$lat2); | ||
| 476 | + $oMap->setsize(256,256); | ||
| 477 | + $oMap->getlayer(0)->set("status",MS_DEFAULT); | ||
| 478 | + $img = $oMap->draw(); | ||
| 479 | + if($img->imagepath == ""){ | ||
| 480 | + exit; | ||
| 481 | + } | ||
| 482 | + salvaCacheImagem($cachedir,$nomeMapfileTmp,$_GET["tms"]); | ||
| 483 | +} | ||
| 484 | +if(strtolower($req->getValueByName("REQUEST")) == "getlegendgraphic"){ | ||
| 485 | + $l = $oMap->getlayer(0); | ||
| 486 | + if($req->getValueByName("LAYER") == ""){ | ||
| 487 | + $req->setParameter("LAYER",$l->name); | ||
| 488 | + } | ||
| 489 | + if($req->getValueByName("FORMAT") == ""){ | ||
| 490 | + $req->setParameter("FORMAT","image/png"); | ||
| 491 | + } | ||
| 492 | +} | ||
| 493 | +if(strtolower($req->getValueByName("REQUEST")) == "getfeature"){ | ||
| 494 | + $l = $oMap->getlayer(0); | ||
| 495 | + if($req->getValueByName("TYPENAME") == "" || $req->getValueByName("TYPENAME") == "undefined"){ | ||
| 496 | + $req->setParameter("TYPENAME",$l->name); | ||
| 497 | + } | ||
| 466 | } | 498 | } |
| 467 | - | ||
| 468 | // | 499 | // |
| 469 | //altera os caminhos das imagens | 500 | //altera os caminhos das imagens |
| 470 | // | 501 | // |
| 471 | if((isset($legenda)) && (strtolower($legenda) == "sim")){ | 502 | if((isset($legenda)) && (strtolower($legenda) == "sim")){ |
| 472 | $leg = $oMap->legend; | 503 | $leg = $oMap->legend; |
| 473 | $leg->set("status",MS_EMBED); | 504 | $leg->set("status",MS_EMBED); |
| 474 | - $cache = false; | ||
| 475 | } | 505 | } |
| 476 | - | ||
| 477 | -ms_ioinstallstdouttobuffer(); | ||
| 478 | - | 506 | +ms_ioinstallstdouttobuffer(); |
| 479 | $oMap->owsdispatch($req); | 507 | $oMap->owsdispatch($req); |
| 480 | $contenttype = ms_iostripstdoutbuffercontenttype(); | 508 | $contenttype = ms_iostripstdoutbuffercontenttype(); |
| 481 | if(strtolower($request) == "getcapabilities"){ | 509 | if(strtolower($request) == "getcapabilities"){ |
| @@ -585,37 +613,46 @@ function ogc_imprimeListaDeTemasWfs(){ | @@ -585,37 +613,46 @@ function ogc_imprimeListaDeTemasWfs(){ | ||
| 585 | } | 613 | } |
| 586 | echo $imprimir."</body></html>"; | 614 | echo $imprimir."</body></html>"; |
| 587 | } | 615 | } |
| 588 | -//FIXME cache fora do novo padrao de xyz | ||
| 589 | -function carregaCacheImagem($bbox,$layer,$w,$h,$cachedir=""){ | ||
| 590 | - global $dir_tmp; | ||
| 591 | - $nome = $w.$h.$bbox.".png"; | ||
| 592 | - if($cachedir == "") | ||
| 593 | - { | ||
| 594 | - $nome = $dir_tmp."/cache/".$layer."/".$nome; | ||
| 595 | - } | ||
| 596 | - else | ||
| 597 | - {$nome = $cachedir."/".$layer."/".$nome; | ||
| 598 | - } | ||
| 599 | - if(file_exists($nome)){ | ||
| 600 | - ob_start(); | ||
| 601 | - // assuming you have image data in $imagedata | ||
| 602 | - $img = file_get_contents($nome); | ||
| 603 | - $length = strlen($img); | ||
| 604 | - $ft = filemtime($nome); | ||
| 605 | - if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && (strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]) == $ft)) { | ||
| 606 | - // Client's cache IS current, so we just respond '304 Not Modified'. | ||
| 607 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 304); | ||
| 608 | - } else { | ||
| 609 | - // Image not cached or cache outdated, we respond '200 OK' and output the image. | ||
| 610 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 200); | ||
| 611 | - } | ||
| 612 | - header('Accept-Ranges: bytes'); | ||
| 613 | - header('Content-Length: '.$length); | ||
| 614 | - header('Content-Type: image/png'); | ||
| 615 | - print($img); | ||
| 616 | - ob_end_flush(); | ||
| 617 | - exit; | 616 | +function carregaCacheImagem($cachedir,$map,$tms){ |
| 617 | + global $dir_tmp; | ||
| 618 | + if($cachedir == ""){ | ||
| 619 | + $nome = $dir_tmp."/cache".$tms; | ||
| 620 | + } | ||
| 621 | + else{ | ||
| 622 | + $nome = $cachedir.$tms; | ||
| 623 | + } | ||
| 624 | + if(file_exists($nome)){ | ||
| 625 | + header('Content-Length: '.filesize($nome)); | ||
| 626 | + header('Content-Type: image/png'); | ||
| 627 | + header('Cache-Control: max-age=3600, must-revalidate'); | ||
| 628 | + header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | ||
| 629 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); | ||
| 630 | + $etag = md5_file($nome); | ||
| 631 | + header('Etag: '.$etag); | ||
| 632 | + fpassthru(fopen($nome, 'rb')); | ||
| 633 | + exit; | ||
| 634 | + } | ||
| 635 | +} | ||
| 636 | +function salvaCacheImagem($cachedir,$map,$tms){ | ||
| 637 | + global $img,$dir_tmp; | ||
| 638 | + if($cachedir == ""){ | ||
| 639 | + $nome = $dir_tmp."/cache".$tms; | ||
| 618 | } | 640 | } |
| 641 | + else{ | ||
| 642 | + $nome = $cachedir.$tms; | ||
| 643 | + } | ||
| 644 | + @mkdir(dirname($nome),0777,true); | ||
| 645 | + chmod(dirname($nome),0777); | ||
| 646 | + $img->saveImage($nome); | ||
| 647 | + chmod($nome,0777); | ||
| 648 | + | ||
| 649 | + header('Content-Length: '.filesize($nome)); | ||
| 650 | + header('Content-Type: image/png'); | ||
| 651 | + header('Cache-Control: max-age=3600, must-revalidate'); | ||
| 652 | + header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | ||
| 653 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); | ||
| 654 | + fpassthru(fopen($nome, 'rb')); | ||
| 655 | + exit; | ||
| 619 | } | 656 | } |
| 620 | function texto2iso($texto){ | 657 | function texto2iso($texto){ |
| 621 | if (function_exists("mb_convert_encoding")){ | 658 | if (function_exists("mb_convert_encoding")){ |