Commit bc360fd6a518938ef7360e6e2a684b5d33f2a850

Authored by Edmar Moretti
1 parent 842e89d6

Adaptações para versão 7 do Mapserver

aplicmap/geral1debianv7.map
@@ -36,6 +36,7 @@ MAP @@ -36,6 +36,7 @@ MAP
36 UNITS DD 36 UNITS DD
37 NAME "GERAL" 37 NAME "GERAL"
38 DEBUG OFF 38 DEBUG OFF
  39 + #CONFIG "CPL_DEBUG" "ON"
39 #CONFIG "MS_ERRORFILE" "/tmp/ms_tmp/ms_error.txt" 40 #CONFIG "MS_ERRORFILE" "/tmp/ms_tmp/ms_error.txt"
40 # 41 #
41 #utilize o agg apenas com mapserver 5x 42 #utilize o agg apenas com mapserver 5x
classesphp/proxy.php
1 <?php 1 <?php
  2 +/**
  3 + * Utilize proxy.php para acessar URLs por intermedio do servidor, via CURL
  4 + * Voce pode usar o parametro proxy?url=
  5 + * ou entao, enviar a URL e seus parametros apos o sinal "?"
  6 + * http://localhost/i3geo/classesphp/proxy.php?http://localhost/i3geo/classesphp/mapa_openlayers.php?g_sid=e7oi2d2645gt712e4cjmt93pf5&TIPOIMAGEM=nenhum&DESLIGACACHE=sim&layer=mundo&REQUEST=getfeature&service=wfs&version=1.0.0&OUTPUTFORMAT=gml2
  7 + *
  8 + * Para controlar o retorno dos dados, utilize o arametro &tipoRetornoProxy, que pode ter os seguintes valores:
  9 + * (se nao for definido retorna no formato nativo)
  10 + *
  11 + * string - retorna o resultado nativo entre aspas simples
  12 + * gml2json - converte um formato GML2 em geoJson (util em chamadas getfeatureinfo)
  13 + */
2 if(!isset($i3geo_proxy_server)){ 14 if(!isset($i3geo_proxy_server)){
3 include(dirname(__FILE__)."/../ms_configura.php"); 15 include(dirname(__FILE__)."/../ms_configura.php");
4 } 16 }
@@ -18,17 +30,54 @@ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -18,17 +30,54 @@ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
18 if(isset($i3geo_proxy_server) && $i3geo_proxy_server != ""){ 30 if(isset($i3geo_proxy_server) && $i3geo_proxy_server != ""){
19 curl_setopt($ch, CURLOPT_PROXY, $i3geo_proxy_server); 31 curl_setopt($ch, CURLOPT_PROXY, $i3geo_proxy_server);
20 } 32 }
21 -$resultado = curl_exec($ch); 33 +$resultado = curl_exec($ch);
  34 +
22 if($_GET["tipoRetornoProxy"] == "string"){ 35 if($_GET["tipoRetornoProxy"] == "string"){
23 echo '"'.$resultado.'"'; 36 echo '"'.$resultado.'"';
24 exit; 37 exit;
25 } 38 }
26 39
27 -if($_GET["tipoRetornoProxy"] == "json"){  
28 - $r = array($resultado);  
29 - //echo json_encode(str_replace(array("\n","\r","\t"),"",$r));  
30 - echo json_encode($r); 40 +if($_GET["tipoRetornoProxy"] == "gml2wkt"){
  41 + echo gml2wkt($resultado);
31 exit; 42 exit;
32 } 43 }
  44 +
33 echo $resultado; 45 echo $resultado;
  46 +
  47 +
  48 +function gml2wkt($gml){
  49 + // Parse GML file
  50 + include("funcoes_gerais.php");
  51 + $k = array_keys($_GET);
  52 + session_name("i3GeoPHP");
  53 + session_id($_GET[$k[0]]);
  54 + session_start();
  55 + //var_dump($_SESSION);exit;
  56 + $nome = $_SESSION["dir_tmp"]."/gml_".nomeRandomico();
  57 + $nomegml = $nome.".gml";
  58 + $nomemap = $_SESSION["map_file"];
  59 + $gml = str_replace("xsi:schemaLocation","erro",$gml);
  60 + gravaDados(array($gml),$nomegml);
  61 + $map = new mapObj($nomemap);
  62 + $layer = ms_newLayerObj($map);
  63 + $layer->setConnectionType(MS_OGR);
  64 + $layer->set("connection",$nomegml);
  65 + $layer->set("template","none.html");
  66 + $layer->set("type",MS_LAYER_POLYGON);
  67 + $layer->set("name",$nome);
  68 + $layer->set("status",MS_DEFAULT);
  69 + $layer->setmetadata("tema",$nome);
  70 + $classe = ms_newClassObj($layer);
  71 + $novoestilo = ms_newStyleObj($classe);
  72 + $ncor = $novoestilo->color;
  73 + $ncor->setrgb(255,255,255);
  74 + //$map->save($nomemap);
  75 + //exit;
  76 + $layer->queryByrect($map->extent);
  77 + $sopen = $layer->open();
  78 + $shape = $layer->getShape($layer->getResult(0));
  79 + $wkt = $shape->towkt();
  80 + return json_encode(array($wkt));
  81 +}
  82 +
34 ?> 83 ?>
35 \ No newline at end of file 84 \ No newline at end of file
ferramentas/editorol/editorol.js
@@ -664,7 +664,6 @@ i3GEO.editorOL = @@ -664,7 +664,6 @@ i3GEO.editorOL =
664 i3GEO.editorOL.mapa.zoomToExtent(b); 664 i3GEO.editorOL.mapa.zoomToExtent(b);
665 }, 665 },
666 mostraLegenda : function() { 666 mostraLegenda : function() {
667 - //TODO testar no mashup  
668 var layers = i3GEO.editorOL.layersLigados(), nlayers = layers.length, ins = "", i, icone = "", url, fers, f = "", fer = ""; 667 var layers = i3GEO.editorOL.layersLigados(), nlayers = layers.length, ins = "", i, icone = "", url, fers, f = "", fer = "";
669 for (i = 0; i < nlayers; i++) { 668 for (i = 0; i < nlayers; i++) {
670 try { 669 try {
@@ -790,26 +789,31 @@ i3GEO.editorOL = @@ -790,26 +789,31 @@ i3GEO.editorOL =
790 "&filter=<Filter><Intersects><PropertyName>Geometry</PropertyName><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:posList>" + poligono 789 "&filter=<Filter><Intersects><PropertyName>Geometry</PropertyName><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:posList>" + poligono
791 + "</gml:posList></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects></Filter>"; 790 + "</gml:posList></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects></Filter>";
792 retorno = function(r){ 791 retorno = function(r){
793 - //FIXME nao funciona  
794 - //parser gml  
795 - var f,c,format;  
796 - /*  
797 - format = new ol.format.GML2({  
798 - featurePrefix: "ms",  
799 - geometryName : "msGeometry",  
800 - featureNS : "http://mapserver.gis.umn.edu/mapserver"  
801 - });  
802 - */  
803 - //console.info(r[0])  
804 - format = new ol.format.GML2();  
805 - f = format.readFeatures(r[0]);  
806 - //console.info(f); 792 + var fs,c,format, f, n, i;
  793 + format = new ol.format.WKT();
  794 + fs = format.readFeatures(r[0]);
  795 + n = fs.length;
807 c = i3GEO.desenho.layergrafico.getSource(); 796 c = i3GEO.desenho.layergrafico.getSource();
808 - c.addFeature(f); 797 + for(i=0; i<n; i++){
  798 + f = fs[i];
  799 + f.setStyle(
  800 + new ol.style.Style({
  801 + stroke: new ol.style.Stroke({
  802 + color: 'rgba(' + i3GEO.editorOL.simbologia.strokeColor + ',' + i3GEO.editorOL.simbologia.opacidade + ')',
  803 + width: i3GEO.editorOL.simbologia.strokeWidth
  804 + }),
  805 + fill: new ol.style.Fill({
  806 + color: 'rgba(' + i3GEO.editorOL.simbologia.fillColor + ',' + i3GEO.editorOL.simbologia.opacidade + ')'
  807 + })
  808 + })
  809 + );
  810 + f.setId(i3GEO.util.uid());
  811 + c.addFeature(f);
  812 + }
809 }; 813 };
810 u = i3GEO.configura.locaplic + "/classesphp/proxy.php?" 814 u = i3GEO.configura.locaplic + "/classesphp/proxy.php?"
811 + u 815 + u
812 - + "&tipoRetornoProxy=json"; 816 + + "&tipoRetornoProxy=gml2wkt";
813 cpJSON.call(u, "foo", retorno, ""); 817 cpJSON.call(u, "foo", retorno, "");
814 }, 818 },
815 salvaGeometrias : function() { 819 salvaGeometrias : function() {
@@ -1566,88 +1570,6 @@ i3GEO.editorOL = @@ -1566,88 +1570,6 @@ i3GEO.editorOL =
1566 adiciona = true; 1570 adiciona = true;
1567 1571
1568 } 1572 }
1569 - if (botoes.identifica === true) {  
1570 - //TODO incluir codigo ol3  
1571 -  
1572 - botaoIdentifica =  
1573 - new OpenLayers.Control.WMSGetFeatureInfo(  
1574 - {  
1575 - maxFeatures : 1,  
1576 - infoFormat : 'text/plain', // 'application/vnd.ogc.gml',  
1577 - layers : [  
1578 - i3GEO.editorOL.layerAtivo()  
1579 - ],  
1580 - queryVisible : true,  
1581 - title : $trad("d7t"),  
1582 - type : OpenLayers.Control.TYPE_TOOL,  
1583 - displayClass : "editorOLidentifica",  
1584 - eventListeners : {  
1585 - getfeatureinfo : function(event) {  
1586 - var lonlat = i3GEO.editorOL.mapa.getLonLatFromPixel(event.xy), lonlattexto = "<hr>", formata;  
1587 - if (botoes.linha === true || botoes.ponto === true || botoes.poligono === true || botoes.edita === true) {  
1588 - lonlattexto +=  
1589 - "<pre><span style=font-size:12px;color:blue;cursor:pointer onclick='i3GEO.editorOL.captura(\"" + lonlat.lon  
1590 - + ","  
1591 - + lonlat.lat  
1592 - + "\")'>edita geometria</span></pre><br>";  
1593 - }  
1594 - formata = function(texto) {  
1595 - var temp, temp1, n, i, f = [], textoN = texto.split(":");  
1596 - try {  
1597 - if (textoN.length > 1) {  
1598 - temp = textoN[2].replace(/\n\r/g, "");  
1599 - temp = temp.replace(/'/g, "");  
1600 - temp = temp.replace(/\n/g, "|");  
1601 - temp = temp.replace(/_/g, " ");  
1602 - temp = temp.replace(/=/g, ":");  
1603 - temp = temp.split("|");  
1604 - n = temp.length;  
1605 - for (i = 0; i < n; i++) {  
1606 - temp1 = temp[i].replace(/^\s+/, "");  
1607 - temp1 = temp1.replace(/\s+$/, "");  
1608 - if (temp1 != "")  
1609 - f.push(temp1);  
1610 - }  
1611 - texto = f.join("<br><br>");  
1612 - }  
1613 - } catch (e) {  
1614 - }  
1615 - return texto;  
1616 - };  
1617 - i3GEO.editorOL.mapa.addPopup(new OpenLayers.Popup.FramedCloud("chicken", i3GEO.editorOL.mapa  
1618 - .getLonLatFromPixel(event.xy), null, "<div style=text-align:left >" + lonlattexto  
1619 - + "<pre>"  
1620 - + formata(event.text)  
1621 - + "</pre></div>", null, true));  
1622 - i3GEO.editorOL.removeClone();  
1623 - },  
1624 - beforegetfeatureinfo : function(event) {  
1625 - var ativo = [  
1626 - i3GEO.editorOL.layerAtivo()  
1627 - ];  
1628 - // se for TMS tem de pegar o clone wms  
1629 - if (ativo[0].serviceVersion === "&tms=" || ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS"  
1630 - || ativo[0].CLASS_NAME == "OpenLayers.Layer.OSM") {  
1631 - ativo = [  
1632 - i3GEO.editorOL.layertms2wms(ativo[0])  
1633 - ];  
1634 - }  
1635 - ativo[0].projection = new OpenLayers.Projection("EPSG:4326");  
1636 - event.object.layers = ativo;  
1637 - botaoIdentifica.layers = ativo;  
1638 - botaoIdentifica.url = ativo[0].url;  
1639 - },  
1640 - activate : function() {  
1641 - i3GEO.editorOL.criaJanelaAtivaTema();  
1642 - }  
1643 - }  
1644 - });  
1645 - // button.events.register("getfeatureinfo", this, showInfo);  
1646 - controles.push(botaoIdentifica);  
1647 - adiciona = true;  
1648 -  
1649 - }  
1650 -  
1651 */ 1573 */
1652 }, 1574 },
1653 removeFeaturesSel : function(){ 1575 removeFeaturesSel : function(){
temas/_ltestegml.map
@@ -3,10 +3,11 @@ MAP @@ -3,10 +3,11 @@ MAP
3 SYMBOLSET "../symbols/simbolos.sym" 3 SYMBOLSET "../symbols/simbolos.sym"
4 LAYER 4 LAYER
5 CONNECTION "/var/www/i3geo/aplicmap/dados/ucsfi.gml" 5 CONNECTION "/var/www/i3geo/aplicmap/dados/ucsfi.gml"
  6 + #CONNECTION "/tmp/ms_tmp/gml_UGJUDdOMyt.gml"
6 CONNECTIONTYPE OGR 7 CONNECTIONTYPE OGR
7 METADATA 8 METADATA
8 "METAESTAT_ID_MEDIDA_VARIAVEL" "" 9 "METAESTAT_ID_MEDIDA_VARIAVEL" ""
9 - "cache" "sim" 10 + "cache" "nao"
10 "CLASSE" "SIM" 11 "CLASSE" "SIM"
11 "permitekmz" "nao" 12 "permitekmz" "nao"
12 "METAESTAT_CODIGO_TIPO_REGIAO" "" 13 "METAESTAT_CODIGO_TIPO_REGIAO" ""