From 2aff3400eb69a0cf2cebc212a61e21ae79c8a70a Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Fri, 13 Dec 2013 01:09:43 +0000 Subject: [PATCH] $1 --- admin/admin.db | Bin 263168 -> 0 bytes admin/php/editormapfile.php | 3 ++- classesphp/mapa_googlemaps.php | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------- mashups/openlayers.js | 74 +++++++++++++++++++++++++++++++++++++++++++++----------------------------- mashups/openlayers_compacto.js | 46 ++++++++++++++++++++++++++++++++-------------- mashups/openlayers_compacto.js.php | 46 ++++++++++++++++++++++++++++++++-------------- temas/_lbairros.map | 26 ++++++++++++++++---------- 7 files changed, 215 insertions(+), 103 deletions(-) diff --git a/admin/admin.db b/admin/admin.db index 73b0a19..8e7c6b8 100644 Binary files a/admin/admin.db and b/admin/admin.db differ diff --git a/admin/php/editormapfile.php b/admin/php/editormapfile.php index 58e21ac..b516808 100644 --- a/admin/php/editormapfile.php +++ b/admin/php/editormapfile.php @@ -1620,7 +1620,8 @@ function alterarEditavel() $layer->setmetadata("COLUNAIDUNICO",$colunaidunico); $layer->setmetadata("TABELAEDITAVEL",$tabelaeditavel); $layer->setmetadata("ESQUEMATABELAEDITAVEL",$esquematabelaeditavel); - $layer->setmetadata("COLUNAGEOMETRIA",$colunageometria); + $layer->setmetadata("COLUNAGEOMETRIA",$colunageometria); + $layer->setmetadata("cache",""); $mapa->save($mapfile); removeCabecalho($mapfile); return "ok"; diff --git a/classesphp/mapa_googlemaps.php b/classesphp/mapa_googlemaps.php index 5f7e26a..1854cb4 100644 --- a/classesphp/mapa_googlemaps.php +++ b/classesphp/mapa_googlemaps.php @@ -88,48 +88,56 @@ else{ if(!isset($_SESSION["map_file"])){ exit; } -// + $map_fileX = $_SESSION["map_file"]; $postgis_mapa = $_SESSION["postgis_mapa"]; $cachedir = $_SESSION["cachedir"]; $i3georendermode = $_SESSION["i3georendermode"]; -// -//converte a requisição do tile em coordenadas geo -//http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#tile_numbers_to_lon.2Flat_2 -// -$x = $_GET["X"]; -$y = $_GET["Y"]; -$z = $_GET["Z"]; - -$qyfile = dirname($map_fileX)."/".$_GET["layer"].".php"; -$qy = file_exists($qyfile); -if($qy == false && $_GET["cache"] == "sim" && $_GET["DESLIGACACHE"] != "sim"){ - carregaCacheImagem(); +if(!empty($_GET["request"])){ + $_GET["REQUEST"] = $_GET["request"]; } +if($_GET["REQUEST"] == "GetFeatureInfo" || strtolower($_GET["REQUEST"]) == "getfeature"){ + $_GET["DESLIGACACHE"] = "sim"; + $_GET["SRS"] = "EPSG:3857"; +} +else{ + // + //converte a requisição do tile em coordenadas geo + //http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#tile_numbers_to_lon.2Flat_2 + // + $x = $_GET["X"]; + $y = $_GET["Y"]; + $z = $_GET["Z"]; + + $qyfile = dirname($map_fileX)."/".$_GET["layer"].".php"; + $qy = file_exists($qyfile); + if($qy == false && $_GET["cache"] == "sim" && $_GET["DESLIGACACHE"] != "sim"){ + carregaCacheImagem(); + } -$n = pow(2,$z); -$lon1 = $x / $n * 360.0 - 180.0; -$lat2 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n)))); -$x++; -$y++; -$lon2 = $x / $n * 360.0 - 180.0; -$lat1 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n)))); -$x--; -$y--; - -$projInObj = ms_newprojectionobj("proj=latlong,a=6378137,b=6378137"); -$projOutObj = ms_newprojectionobj("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m"); - -$poPoint1 = ms_newpointobj(); -$poPoint1->setXY($lon1, $lat1); -$poPoint1->project($projInObj, $projOutObj); -$poPoint2 = ms_newpointobj(); -$poPoint2->setXY($lon2, $lat2); -$poPoint2->project($projInObj, $projOutObj); -$_GET["BBOX"] = $poPoint1->x." ".$poPoint1->y." ".$poPoint2->x." ".$poPoint2->y; -$_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]); - + $n = pow(2,$z); + $lon1 = $x / $n * 360.0 - 180.0; + $lat2 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n)))); + $x++; + $y++; + $lon2 = $x / $n * 360.0 - 180.0; + $lat1 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n)))); + $x--; + $y--; + + $projInObj = ms_newprojectionobj("proj=latlong,a=6378137,b=6378137"); + $projOutObj = ms_newprojectionobj("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m"); + + $poPoint1 = ms_newpointobj(); + $poPoint1->setXY($lon1, $lat1); + $poPoint1->project($projInObj, $projOutObj); + $poPoint2 = ms_newpointobj(); + $poPoint2->setXY($lon2, $lat2); + $poPoint2->project($projInObj, $projOutObj); + $_GET["BBOX"] = $poPoint1->x." ".$poPoint1->y." ".$poPoint2->x." ".$poPoint2->y; + $_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]); +} $mapa = ms_newMapObj($map_fileX); $ret = $mapa->extent; @@ -175,6 +183,18 @@ if(!isset($_GET["telaR"])){ if(strtolower($l->getmetadata("cache")) == "sim"){ $cache = true; } + if($_GET["REQUEST"] == "GetFeatureInfo" || strtolower($_GET["REQUEST"]) == "getfeature" ){ + $l->setmetadata("gml_include_items","all"); + $l->set("template","none.htm"); + $l->setmetadata("WMS_INCLUDE_ITEMS","all"); + $l->setmetadata("WFS_INCLUDE_ITEMS","all"); + $l->setmetadata("ows_enable_request","*"); + $l->set("dump",MS_TRUE); + $l->setmetadata("ows_srs","AUTO"); + if(strtolower($_GET["REQUEST"]) == "getfeature"){ + $_GET["TYPENAME"] = $l->name; + } + } } } } @@ -187,6 +207,39 @@ else{ {$l->setProjection("proj=latlong,a=6378137,b=6378137");} } } + +// +//qd a cahamda e para um WMS, redireciona para ogc.php +// +if($_GET["REQUEST"] == "GetFeatureInfo" || $_GET["REQUEST"] == "getfeature"){ + //echo $_GET["mapext"];exit; + if($_GET["REQUEST"] == "GetFeatureInfo"){ + $mapa->setsize(256,256); + $mapext = explode(",",$_GET["BBOX"]); + $mapa->setExtent($mapext[0],$mapext[1],$mapext[2],$mapext[3]); + } + else{ + $mapa->setExtent(-21309420.490489,-8061966.246171,21505099.28287,16906647.661876); + } + $req = ms_newowsrequestobj(); + $_GET = array_merge($_GET,$_POST); + foreach ($_GET as $k=>$v){ + $req->setParameter($k, $v); + } + $proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://"; + $server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; + $or = $proto.$server.$_SERVER['PHP_SELF']; + $mapa->setmetadata("wfs_onlineresource",$or."?".$_SERVER["QUERY_STRING"]); + + ms_ioinstallstdouttobuffer(); + $mapa->owsdispatch($req); + $contenttype = ms_iostripstdoutbuffercontenttype(); + header("Content-type: $contenttype"); + ms_iogetStdoutBufferBytes(); + ms_ioresethandlers(); + exit; +} + if($_GET["layer"] == "") {$cache = true;} diff --git a/mashups/openlayers.js b/mashups/openlayers.js index 1b02b1c..91eb0f3 100755 --- a/mashups/openlayers.js +++ b/mashups/openlayers.js @@ -302,22 +302,25 @@ i3GEO.editorOL = { return false; }, layertms2wms: function(tms){ - var layer = new OpenLayers.Layer.WMS( + var layer,url; + url = tms.url.replace("&cache=sim","&DESLIGACACHE=sim"); + url = url.replace("&Z=${z}&X=${x}&Y=${y}",""); + layer = new OpenLayers.Layer.WMS( tms.layername+"_clone", - tms.url.replace("&cache=sim","&DESLIGACACHE=sim"), - { - layers:tms.name, - transparent:true - }, - { - gutter:0, - isBaseLayer:false, - displayInLayerSwitcher:false, - opacity: 1, - visibility:true, - singleTile: true - } - ); + url, + { + layers:tms.name, + transparent:true + }, + { + gutter:0, + isBaseLayer:false, + displayInLayerSwitcher:false, + opacity: 1, + visibility:true, + singleTile: true + } + ); //i3GEO.editorOL.mapa.addLayer(layer); return layer; }, @@ -589,9 +592,11 @@ i3GEO.editorOL = { //if(i3GEO.editorOL.layergrafico !== ""){return;} var layers = [i3GEO.editorOL.layerAtivo()], xy = lonlat.split(","), - u = layers[0].url+"&request=getfeature&service=wfs&version=1.0.0"; + u = layers[0].url+"&REQUEST=getfeature&service=wfs&version=1.0.0"; u += "&OUTPUTFORMAT=gml2&typename="+layers[0].params.LAYERS; - + //remove parametros nao desejados + u = u.replace("&cache=sim","&DESLIGACACHE=sim"); + u = u.replace("&Z=${z}&X=${x}&Y=${y}",""); //u += "&filter=Geometry"+lonlat+""; xy[0] = xy[0] * 1; @@ -679,20 +684,21 @@ i3GEO.editorOL = { listaGeometriasSel: function(){ var geos = i3GEO.editorOL.layergrafico.selectedFeatures, n = geos.length, - ins = "",i,a,w; + ins = "",i,a,w,g; for(i=0;i
"+geos[i].geometry+"

"; + g = geos[i]; + ins += "Geometria: "+i+"
"+i3GEO.editorOL.google2wgs(g.geometry)+"

"; ins += "Atributos: "+i+"
"; - a = geos[i].attributes; + a = g.attributes; for(key in a){ if(a[key]){ ins += key+" = "+a[key]+"
"; } } //lista os registros se for fruto de uma captura - if(geos[i].attributes.registros){ + if(g.attributes.registros){ ins += "Registros: "+i+"
"; - a = geos[i].attributes.registros; + a = g.attributes.registros; for(key in a){ if(a[key]){ ins += key+" = "+a[key]+"
"; @@ -718,7 +724,8 @@ i3GEO.editorOL = { var registros = "", valorunico = "", nometema = $i("editorOLcomboTemaEditavel").value, - key,tema,redesenha,p; + key="",tema,redesenha,p, + g = i3GEO.editorOL.google2wgs(geos[0].geometry); if(nometema == ""){ return; } @@ -744,12 +751,12 @@ i3GEO.editorOL = { //cria um novo registro if(valorunico == ""){ p = i3GEO.configura.locaplic+"/ferramentas/editortema/exec.php?funcao=adicionaGeometria&g_sid="+i3GEO.configura.sid; - cpJSON.call(p,"foo",redesenha,"&tema="+nometema+"&wkt="+geos[0].geometry); + cpJSON.call(p,"foo",redesenha,"&tema="+nometema+"&wkt="+g); } else{ //atualiza a geometria p = i3GEO.configura.locaplic+"/ferramentas/editortema/exec.php?funcao=atualizaGeometria&g_sid="+i3GEO.configura.sid; - cpJSON.call(p,"foo",redesenha,"&idunico="+valorunico+"&tema="+nometema+"&wkt="+geos[0].geometry); + cpJSON.call(p,"foo",redesenha,"&idunico="+valorunico+"&tema="+nometema+"&wkt="+g); } } }, @@ -939,7 +946,6 @@ i3GEO.editorOL = { var lonlat = i3GEO.editorOL.mapa.getLonLatFromPixel(event.xy), lonlattexto = "
", formata; - if( botoes.linha === true || botoes.ponto === true || botoes.poligono === true || botoes.edita === true){ lonlattexto += "
edita geometria

"; } @@ -982,9 +988,9 @@ i3GEO.editorOL = { i3GEO.editorOL.removeClone(); }, beforegetfeatureinfo: function(event){ - var temp,ativo = [i3GEO.editorOL.layerAtivo()]; + var ativo = [i3GEO.editorOL.layerAtivo()]; //se for TMS tem de pegar o clone wms - if(ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS"){ + if(ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS" || ativo[0].CLASS_NAME == "OpenLayers.Layer.OSM"){ ativo = [i3GEO.editorOL.layertms2wms(ativo[0])]; } event.object.layers = ativo; @@ -1397,7 +1403,7 @@ i3GEO.editorOL = { } }); // - //adiciona o painel ao mapa se alguma op��o foi inserida + //adiciona o painel ao mapa se alguma opcao foi inserida // if(adiciona === true){ i3GEOpanelEditor.addControls(controles); @@ -1935,5 +1941,15 @@ i3GEO.editorOL = { desativaRodaDoMouse: function(){ var controls = i3GEO.editorOL.mapa.getControlsByClass('OpenLayers.Control.Navigation'); for(var i = 0; i"; xy[0] = xy[0] * 1; xy[1] = xy[1] * 1; @@ -3687,20 +3693,21 @@ i3GEO.editorOL.processageo("converteSHP"); listaGeometriasSel: function(){ var geos = i3GEO.editorOL.layergrafico.selectedFeatures, n = geos.length, -ins = "",i,a,w; +ins = "",i,a,w,g; for(i=0;i
"+geos[i].geometry+"

"; +g = geos[i]; +ins += "Geometria: "+i+"
"+i3GEO.editorOL.google2wgs(g.geometry)+"

"; ins += "Atributos: "+i+"
"; -a = geos[i].attributes; +a = g.attributes; for(key in a){ if(a[key]){ ins += key+" = "+a[key]+"
"; } } //lista os registros se for fruto de uma captura -if(geos[i].attributes.registros){ +if(g.attributes.registros){ ins += "Registros: "+i+"
"; -a = geos[i].attributes.registros; +a = g.attributes.registros; for(key in a){ if(a[key]){ ins += key+" = "+a[key]+"
"; @@ -3726,7 +3733,8 @@ if(geos[0].geometry){ var registros = "", valorunico = "", nometema = $i("editorOLcomboTemaEditavel").value, -key,tema,redesenha,p; +key="",tema,redesenha,p, +g = i3GEO.editorOL.google2wgs(geos[0].geometry); if(nometema == ""){ return; } @@ -3751,12 +3759,12 @@ i3GEO.janela.AGUARDEMODAL = false; //cria um novo registro if(valorunico == ""){ p = i3GEO.configura.locaplic+"/ferramentas/editortema/exec.php?funcao=adicionaGeometria&g_sid="+i3GEO.configura.sid; -cpJSON.call(p,"foo",redesenha,"&tema="+nometema+"&wkt="+geos[0].geometry); +cpJSON.call(p,"foo",redesenha,"&tema="+nometema+"&wkt="+g); } else{ //atualiza a geometria p = i3GEO.configura.locaplic+"/ferramentas/editortema/exec.php?funcao=atualizaGeometria&g_sid="+i3GEO.configura.sid; -cpJSON.call(p,"foo",redesenha,"&idunico="+valorunico+"&tema="+nometema+"&wkt="+geos[0].geometry); +cpJSON.call(p,"foo",redesenha,"&idunico="+valorunico+"&tema="+nometema+"&wkt="+g); } } }, @@ -3988,9 +3996,9 @@ true i3GEO.editorOL.removeClone(); }, beforegetfeatureinfo: function(event){ -var temp,ativo = [i3GEO.editorOL.layerAtivo()]; +var ativo = [i3GEO.editorOL.layerAtivo()]; //se for TMS tem de pegar o clone wms -if(ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS"){ +if(ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS" || ativo[0].CLASS_NAME == "OpenLayers.Layer.OSM"){ ativo = [i3GEO.editorOL.layertms2wms(ativo[0])]; } event.object.layers = ativo; @@ -4402,7 +4410,7 @@ if(document.getElementById("panellistagEditor")) } }); // -//adiciona o painel ao mapa se alguma op��o foi inserida +//adiciona o painel ao mapa se alguma opcao foi inserida // if(adiciona === true){ i3GEOpanelEditor.addControls(controles); @@ -4934,5 +4942,15 @@ ls.maximizeDiv.click(); desativaRodaDoMouse: function(){ var controls = i3GEO.editorOL.mapa.getControlsByClass('OpenLayers.Control.Navigation'); for(var i = 0; i"; xy[0] = xy[0] * 1; xy[1] = xy[1] * 1; @@ -3687,20 +3693,21 @@ i3GEO.editorOL.processageo("converteSHP"); listaGeometriasSel: function(){ var geos = i3GEO.editorOL.layergrafico.selectedFeatures, n = geos.length, -ins = "",i,a,w; +ins = "",i,a,w,g; for(i=0;i
"+geos[i].geometry+"

"; +g = geos[i]; +ins += "Geometria: "+i+"
"+i3GEO.editorOL.google2wgs(g.geometry)+"

"; ins += "Atributos: "+i+"
"; -a = geos[i].attributes; +a = g.attributes; for(key in a){ if(a[key]){ ins += key+" = "+a[key]+"
"; } } //lista os registros se for fruto de uma captura -if(geos[i].attributes.registros){ +if(g.attributes.registros){ ins += "Registros: "+i+"
"; -a = geos[i].attributes.registros; +a = g.attributes.registros; for(key in a){ if(a[key]){ ins += key+" = "+a[key]+"
"; @@ -3726,7 +3733,8 @@ if(geos[0].geometry){ var registros = "", valorunico = "", nometema = $i("editorOLcomboTemaEditavel").value, -key,tema,redesenha,p; +key="",tema,redesenha,p, +g = i3GEO.editorOL.google2wgs(geos[0].geometry); if(nometema == ""){ return; } @@ -3751,12 +3759,12 @@ i3GEO.janela.AGUARDEMODAL = false; //cria um novo registro if(valorunico == ""){ p = i3GEO.configura.locaplic+"/ferramentas/editortema/exec.php?funcao=adicionaGeometria&g_sid="+i3GEO.configura.sid; -cpJSON.call(p,"foo",redesenha,"&tema="+nometema+"&wkt="+geos[0].geometry); +cpJSON.call(p,"foo",redesenha,"&tema="+nometema+"&wkt="+g); } else{ //atualiza a geometria p = i3GEO.configura.locaplic+"/ferramentas/editortema/exec.php?funcao=atualizaGeometria&g_sid="+i3GEO.configura.sid; -cpJSON.call(p,"foo",redesenha,"&idunico="+valorunico+"&tema="+nometema+"&wkt="+geos[0].geometry); +cpJSON.call(p,"foo",redesenha,"&idunico="+valorunico+"&tema="+nometema+"&wkt="+g); } } }, @@ -3988,9 +3996,9 @@ true i3GEO.editorOL.removeClone(); }, beforegetfeatureinfo: function(event){ -var temp,ativo = [i3GEO.editorOL.layerAtivo()]; +var ativo = [i3GEO.editorOL.layerAtivo()]; //se for TMS tem de pegar o clone wms -if(ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS"){ +if(ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS" || ativo[0].CLASS_NAME == "OpenLayers.Layer.OSM"){ ativo = [i3GEO.editorOL.layertms2wms(ativo[0])]; } event.object.layers = ativo; @@ -4402,7 +4410,7 @@ if(document.getElementById("panellistagEditor")) } }); // -//adiciona o painel ao mapa se alguma op��o foi inserida +//adiciona o painel ao mapa se alguma opcao foi inserida // if(adiciona === true){ i3GEOpanelEditor.addControls(controles); @@ -4934,6 +4942,16 @@ ls.maximizeDiv.click(); desativaRodaDoMouse: function(){ var controls = i3GEO.editorOL.mapa.getControlsByClass('OpenLayers.Control.Navigation'); for(var i = 0; i