Commit a6982646bc3905e8cf4950de153c68b60860460e
1 parent
a4b4d748
Exists in
master
and in
7 other branches
Correção na função de identificação de atributos quando o tema em foco é um WMS.…
… Alguns WMS exigem a definição do parâmetro format na requisição getfeatureinfo, entretanto, quando format é definido na requisição, WMS gerados pelo Mapserver geram erros. O problema foi corrigido criticando-se o resultado da chamada getfeatureinfo.
Showing
6 changed files
with
55 additions
and
23 deletions
Show diff stats
classesphp/classe_atributos.php
... | ... | @@ -710,6 +710,19 @@ function identificaQBP($tema,$x,$y,$map_file,$resolucao,$item,$tiporetorno="") |
710 | 710 | $res .= "&Y=".round($ptimg->y); |
711 | 711 | $res .= "&WIDTH=".$mapa->width; |
712 | 712 | $res .= "&HEIGHT=".$mapa->height; |
713 | + $formatoinfo = "text/plain"; | |
714 | + $formatosinfo = $layer->getmetadata("formatosinfo"); | |
715 | + if ($formatosinfo != "") | |
716 | + { | |
717 | + $formatosinfo = explode(",",$formatosinfo); | |
718 | + if ($formatosinfo[0] != ""){$formatoinfo = $formatosinfo[0];} | |
719 | + foreach ($formatosinfo as $f) | |
720 | + { | |
721 | + if(strtoupper($f) == "TEXT/PLAIN") | |
722 | + {$formatoinfo = "text/plain";} | |
723 | + } | |
724 | + | |
725 | + } | |
713 | 726 | $srs = $layer->getmetadata("wms_srs"); |
714 | 727 | $srss = explode(" ",$srs); |
715 | 728 | $srs = "EPSG:4326"; |
... | ... | @@ -719,23 +732,25 @@ function identificaQBP($tema,$x,$y,$map_file,$resolucao,$item,$tiporetorno="") |
719 | 732 | {$srs = "EPSG:4291";} |
720 | 733 | } |
721 | 734 | $res .= "&SRS=".$srs; |
722 | - $res = file($res); | |
723 | - $res = str_ireplace('<?xml version="1.0" encoding="UTF-8"?>',"",$res); | |
724 | - $res = str_ireplace('<?xml version="1.0" encoding="ISO-8859-1"?>',"",$res); | |
725 | - $res = str_ireplace("<?xml version='1.0' encoding='ISO-8859-1'?>","",$res); | |
726 | - $res = str_ireplace('<?xml',"",$res); | |
727 | - $res = str_ireplace("<","zzzzzzzzzz",$res); | |
728 | - $res = str_ireplace(">","zzzzzzzzzz",$res); | |
729 | - $resultado[] = $res; | |
735 | + $resposta = file($res."&FORMAT=".$formatoinfo); | |
736 | + $resposta = str_ireplace('<?xml version="1.0" encoding="UTF-8"?>',"",$resposta); | |
737 | + $resposta = str_ireplace('<?xml version="1.0" encoding="ISO-8859-1"?>',"",$resposta); | |
738 | + $resposta = str_ireplace("<?xml version='1.0' encoding='ISO-8859-1'?>","",$resposta); | |
739 | + $resposta = str_ireplace('<?xml',"",$resposta); | |
740 | + $resposta = str_ireplace("<","zzzzzzzzzz",$resposta); | |
741 | + $resposta = str_ireplace(">","zzzzzzzzzz",$resposta); | |
742 | + if (stristr(implode(" ",$resposta),"msWMSLoadGetMapParams")) | |
743 | + { | |
744 | + $resposta = file($res); | |
745 | + $resposta = str_ireplace('<?xml version="1.0" encoding="UTF-8"?>',"",$resposta); | |
746 | + $resposta = str_ireplace('<?xml version="1.0" encoding="ISO-8859-1"?>',"",$resposta); | |
747 | + $resposta = str_ireplace("<?xml version='1.0' encoding='ISO-8859-1'?>","",$resposta); | |
748 | + $resposta = str_ireplace('<?xml',"",$resposta); | |
749 | + $resposta = str_ireplace("<","zzzzzzzzzz",$resposta); | |
750 | + $resposta = str_ireplace(">","zzzzzzzzzz",$resposta); | |
751 | + } | |
752 | + $resultado[] = $resposta; | |
730 | 753 | return $resultado; |
731 | - $lines = file($res); | |
732 | - $lines = str_ireplace("<html>","",$lines); | |
733 | - $lines = str_ireplace("<body>","",$lines); | |
734 | - $lines = str_ireplace("</html>","",$lines); | |
735 | - $lines = str_ireplace("</body>","",$lines); | |
736 | - $lines = str_ireplace("#","",$lines); | |
737 | - $resultado[] = $lines; | |
738 | - return $resultado; | |
739 | 754 | } |
740 | 755 | if(($layer->connectiontype != MS_WMS) && ($layer->type == MS_LAYER_RASTER)) |
741 | 756 | { | ... | ... |
classesphp/classe_mapa.php
... | ... | @@ -795,20 +795,18 @@ $imgdir - diretório temporário das imagens |
795 | 795 | $imgurl - url do imgdir |
796 | 796 | $tiporep - tipo de representação das feições do mapa |
797 | 797 | $suportasld - Suporta SLD sim|nao. |
798 | - | |
798 | +$formatosinfo - lista de formatos da requisição de atributos para a função getfeatureinfo (default text/plain) | |
799 | 799 | Include: |
800 | 800 | <wmswfs.php> |
801 | 801 | */ |
802 | - function adicionatemawms($tema,$servico,$nome,$proj,$formato,$locaplic,$tipo,$versao,$nomecamada,$dir_tmp,$imgdir,$imgurl,$tiporep,$suportasld) | |
802 | + function adicionatemawms($tema,$servico,$nome,$proj,$formato,$locaplic,$tipo,$versao,$nomecamada,$dir_tmp,$imgdir,$imgurl,$tiporep,$suportasld,$formatosinfo="text/plain") | |
803 | 803 | { |
804 | 804 | require_once("wmswfs.php"); |
805 | 805 | //limpa selecao |
806 | 806 | if (file_exists(($this->arquivo)."qy")) |
807 | 807 | {unlink (($this->arquivo)."qy");} |
808 | - | |
809 | 808 | $nmap = ms_newMapObj($locaplic."/aplicmap/novotema.map"); |
810 | 809 | $layer = $nmap->getlayerbyname("novotema"); |
811 | - | |
812 | 810 | $layer->set("name",$tema); |
813 | 811 | $layer->set("status",MS_DEFAULT); |
814 | 812 | $layer->setmetadata("tema",$nomecamada); |
... | ... | @@ -856,6 +854,7 @@ Include: |
856 | 854 | $layer->setmetadata("wms_name",$tema); |
857 | 855 | $layer->setmetadata("wms_server_version",$versao); |
858 | 856 | $layer->setmetadata("wms_formatlist",$formato); |
857 | + $layer->setmetadata("formatosinfo",$formatosinfo); | |
859 | 858 | $layer->setmetadata("wms_exceptions_format","application/vnd.ogc.se_xml"); |
860 | 859 | $layer->setmetadata("wms_style",$nome); |
861 | 860 | $layer->setmetadata("wms_connectiontimeout","30"); | ... | ... |
classesphp/mapa_controle.php
... | ... | @@ -636,7 +636,7 @@ Include: |
636 | 636 | case "adicionatemawms": |
637 | 637 | include("classe_mapa.php"); |
638 | 638 | $m = new Mapa($map_file); |
639 | - $m->adicionatemawms($tema,$servico,$nome,$proj,$formato,$locaplic,$tipo,$versao,$nomecamada,$dir_tmp,$imgdir,$imgurl,$tiporep,$suportasld); | |
639 | + $m->adicionatemawms($tema,$servico,$nome,$proj,$formato,$locaplic,$tipo,$versao,$nomecamada,$dir_tmp,$imgdir,$imgurl,$tiporep,$suportasld,$formatosinfo); | |
640 | 640 | $teste = $m->mapa->draw(); |
641 | 641 | $retorno = "ok"; |
642 | 642 | if ($teste != "") | ... | ... |
classesphp/wmswfs.php
... | ... | @@ -323,7 +323,8 @@ function temaswms() |
323 | 323 | } |
324 | 324 | } |
325 | 325 | $retorna[] = "<br>Proj.:<input size=30 id=proj type=text class=digitar value='".implode(",",wms_srs($dom))."'/><br>"; |
326 | - $retorna[] = "<br>Formatos:<input size=30 id=formatos type=text class=digitar value='".implode(",",wms_formats($dom))."'/><br><br>"; | |
326 | + $retorna[] = "<br>Formatos imagem:<input size=30 id=formatos type=text class=digitar value='".implode(",",wms_formats($dom))."'/><br><br>"; | |
327 | + $retorna[] = "<br>Formatos info:<input size=30 id=formatosinfo type=text class=digitar value='".implode(",",wms_formatsinfo($dom))."'/><br><br>"; | |
327 | 328 | $retorna[] = "<br>Versao:<input size=30 id=versao type=text class=digitar value='".(wms_version($dom))."'/><br><br>"; |
328 | 329 | $retorna[] = "<br>Suporta SLD:<input size=30 id=suportasld type=text class=digitar value='".$suporta."'/><br><br><br>"; |
329 | 330 | $cp->set_data(implode($retorna)); |
... | ... | @@ -500,6 +501,23 @@ function wms_formats ( $dom ) |
500 | 501 | return $arr; |
501 | 502 | } |
502 | 503 | /* |
504 | +function: wms_formatsinfo | |
505 | + | |
506 | +Retorna os formatos existentes de retorno da opção getfeatureinfo. | |
507 | +*/ | |
508 | +function wms_formatsinfo ( $dom ) | |
509 | +{ | |
510 | + $xpath = new DOMXPath($dom); | |
511 | + $query = '//WMT_MS_Capabilities/Capability/Request/GetFeatureInfo/Format'; | |
512 | + $entries = $xpath->query($query); | |
513 | + $arr = array(); | |
514 | + foreach ($entries as $entry) | |
515 | + { | |
516 | + $arr[] = $entry->nodeValue; | |
517 | + } | |
518 | + return $arr; | |
519 | +} | |
520 | +/* | |
503 | 521 | function: wms_estilos |
504 | 522 | |
505 | 523 | Retorna os estilos de um WMS. | ... | ... |
ferramentas/conectarwms/index.js
... | ... | @@ -139,7 +139,7 @@ function adiciona() |
139 | 139 | } |
140 | 140 | aguarde("block"); |
141 | 141 | var tiporep = $i("tiporep").value |
142 | - var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=adicionatemawms&servico="+$i("servico").value+"&tema="+g_tema+"&nome="+g_nometema+"&proj="+$i("proj").value+"&formato="+$i("formatos").value+"&tipo="+g_tipo+"&versao="+$i("versao").value+"&nomecamada="+g_nomecamada+"&tiporep="+tiporep+"&suportasld="+g_sld | |
142 | + var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=adicionatemawms&servico="+$i("servico").value+"&tema="+g_tema+"&nome="+g_nometema+"&proj="+$i("proj").value+"&formato="+$i("formatos").value+"&tipo="+g_tipo+"&versao="+$i("versao").value+"&nomecamada="+g_nomecamada+"&tiporep="+tiporep+"&suportasld="+g_sld+"&formatosinfo="+$i("formatosinfo").value | |
143 | 143 | var cp = new cpaint(); |
144 | 144 | //cp.set_debug(2) |
145 | 145 | cp.set_response_type("JSON"); | ... | ... |