Commit 43f2d76f66cc67f48783ee291a9a6fde4ef04db8

Authored by Edmar Moretti
1 parent 92d815c5

Correção no uso de JSON na requisição WMS getfeatureinfo

aplicmap/ogcws.map
... ... @@ -105,6 +105,8 @@ MAP
105 105 "ows_namespace_uri" "http://www.omsug.ca/osgis2004"
106 106 "ows_address" "http://www.mma.gov.br"
107 107 "ows_postcode" ""
  108 + "wms_info" "1.1.1"
  109 + "wms_feature_info_mime_type" "application/json"
108 110 "ows_enable_request" "*"
109 111 END
110 112 QUERYFORMAT text/html
... ...
aplicmap/ogcwsv5.map
... ... @@ -107,6 +107,7 @@ MAP
107 107 "ows_address" "http://www.mma.gov.br"
108 108 "ows_postcode" ""
109 109 "ows_enable_request" "*"
  110 + "wms_feature_info_mime_type" "application/json"
110 111 END
111 112 QUERYFORMAT text/html
112 113 LEGENDFORMAT text/html
... ...
aplicmap/ogcwsv6.map
... ... @@ -138,6 +138,7 @@ MAP
138 138 "ows_postcode" ""
139 139 "ows_enable_request" "*"
140 140 "ows_sld_enabled" "true"
  141 + "wms_feature_info_mime_type" "application/json"
141 142 END
142 143 QUERYFORMAT text/html
143 144 LEGENDFORMAT text/html
... ...
classesphp/funcoes_gerais.php
... ... @@ -2201,6 +2201,7 @@ function getRGBpallete($rule, $value){
2201 2201 $b=$rule["b0"] + round(($rule["b1"]-$rule["b0"])*$escala, 0);
2202 2202 return array($r,$g,$b);
2203 2203 }
  2204 +//TODO verificar ao fechar versao
2204 2205 /*
2205 2206 Function: removeAcentos
2206 2207  
... ... @@ -2216,7 +2217,7 @@ Retorno:
2216 2217 */
2217 2218 function removeAcentos($var)
2218 2219 {
2219   - $a = array('�', 'Á', 'Â', 'Ã', '�', '�', '�', 'Ç', '�', 'É', 'Ê', '�', '�', 'Í', '�', '�', '�', '�', '�', '�', 'Ô', 'Õ', '�', '�', '�', 'Ú', '�', '�', '�', '�', '�', 'á', 'â', 'ã', '�', '�', '�', 'ç', '�', 'é', 'ê', '�', '�', 'í', '�', '�', '�', '�', '�', 'ô', 'õ', '�', '�', '�', 'ú', '�', '�', '�', '�', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', '�', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', '?', '?', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', '?', '?', 'L', 'l', 'N', 'n', 'N', 'n', 'N', 'n', '?', 'O', 'o', 'O', 'o', 'O', 'o', '�', '�', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', '�', '�', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', '�', 'Z', 'z', 'Z', 'z', '�', '�', '?', '�', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', '?', '?', '?', '?', '?', '?');
  2220 + $a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'Ð', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', '?', '?', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', '?', '?', 'L', 'l', 'N', 'n', 'N', 'n', 'N', 'n', '?', 'O', 'o', 'O', 'o', 'O', 'o', 'Œ', 'œ', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'Š', 'š', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Ÿ', 'Z', 'z', 'Z', 'z', 'Ž', 'ž', '?', 'ƒ', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', '?', '?', '?', '?', '?', '?');
2220 2221 $b = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o');
2221 2222 return str_replace($a, $b, $var);
2222 2223 }
... ...
guia_de_migracao.txt
... ... @@ -7,6 +7,10 @@ Para a versão 7.0
7 7 -------------------------------------------------------------------------------------------------
8 8 Para a versão 6.0
9 9  
  10 +- para permitir o retorno da requisição WMS getfeatureinfo em JSON, foi incluído no mapfile base utilizado para
  11 +gerar os serviços OGC a linha "wms_feature_info_mime_type" "application/json" em WEB->METADATA
  12 +Caso você utilize um mapfile específico da sua instalação, veja o arquivo original existente em i3geo/aplicmap
  13 +para fazer as adaptações.
10 14  
11 15 - style.overflow passou a ser definido automaticamente como "hidden" para previnir problemas com as janelas de informação.
12 16 Essa definição ocorre apenas quando o elemento body do HTML contiver o id definido como "i3geo" e quando seu estilo
... ... @@ -18,7 +22,7 @@ de informação
18 22 - Inclusão da variável $i3geo_proxy_server no ms_configura.php para uso em algumas operações baseadas no acesso
19 23 a outros servidores via Curl e OGC
20 24  
21   -- Inclusão da variável $statusFerramentas no ms_configura para controlar o status de ferramentas que
  25 +- Inclusão da variável $statusFerramentas no ms_configura para controlar o status de ferramentas que
22 26 dependem de configuração específica do servidor
23 27  
24 28 - Foram incluídos subitens no menu suspenso para acomodar o grande número de opções. Os códigos locais que
... ...
ogc.php
... ... @@ -106,17 +106,6 @@ if(strtolower($OUTPUTFORMAT) == "kml" || strtolower($OUTPUTFORMAT) == "kmz"){
106 106 $urln = "pacotes/kmlmapserver/kmlservice.php?request=kmz&map=".$tema."&typename=".$tema;
107 107 header("Location:".$urln);
108 108 exit;
109   - /*
110   - $l = $oMap->getlayer(0);
111   - $n = $l->name."-kml";
112   - $oMap->selectOutputFormat("kml");
113   - $oMap->outputformat->setOption("STORAGE", "memory");
114   - $oMap->outputformat->setOption("FILENAME", $n.".kml");
115   - $l->setmetadata("wfs_getfeature_formatlist","kml");
116   - $oMap->save($nomeMapfileTmp);
117   - header('Content-Disposition: attachment; filename='.$n.'.kml');
118   - header("Content-type: application/vnd.google-earth.kml+xml");
119   - */
120 109 }
121 110  
122 111 //define um nome para o mapfile caso a origem seja o sistema de metadados estatisticos
... ... @@ -876,42 +865,53 @@ ms_ioinstallstdouttobuffer();
876 865 if(strtolower($req->getValueByName("REQUEST")) == "getmap" && $req->getValueByName("format") == ""){
877 866 $req->setParameter("format","image/png");
878 867 }
879   -
  868 +if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo" && $_GET["info_format"] == "text/xml"){
  869 + $req->setParameter("info_format","application/vnd.ogc.gml");
  870 +}
  871 +//json conforme cesium
880 872 if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo" && $_GET["info_format"] == "application/json"){
881   - //TODO verificar itens e itensdesc
882   - //FIXME essa nao e a melhor forma de fazer o Json
883   - $req->setParameter("info_format","text/plain");
  873 + $req->setParameter("info_format","application/vnd.ogc.gml");
884 874 $oMap->owsdispatch($req);
885 875 ms_iostripstdoutbuffercontentheaders();
886 876 ob_clean();
887 877 $r = ms_iogetstdoutbufferstring();
888   - $t = explode("=",$r);
  878 + //$r = converteenc($r);
  879 + $nome = $oMap->getlayer(0)->name;
  880 + $xml = simplexml_load_string($r);
  881 +
  882 + $json = json_encode($xml);
  883 + $r = json_decode($json,TRUE);
  884 + $propriedades = $r[$nome."_layer"];
  885 + $propriedades = $propriedades[$nome."_feature"];
  886 + $propriedades = converteenc(json_encode($propriedades));
  887 + $propriedades = json_decode($propriedades);
889 888 $n = array();
890   - if(count($t) > 1){
891   - $v = str_replace("\\n","",$t[1]);
892   - $v = str_replace("\\r","",$v);
893   - if(trim($v) != ""){
894   - $va = trim($v);
895   - $coluna = trim(explode(":",$t[0])[2]);
896   - $valor = str_replace("'","",$va);
897   - $n[] = array (
898   - "type" => "FeatureCollection",
899   - "features" => array(
900   - array(
901   - "type"=>"Feature",
902   - "id" => "",
903   - "geometry" => array(),
904   - "properties" => array(
905   - $coluna => $valor
906   - ),
907   - "geometry_name" => ""
908   - )
  889 + $n[] = array (
  890 + "type" => "FeatureCollection",
  891 + "features" => array(
  892 + array(
  893 + "type"=>"Feature",
  894 + "id" => "",
  895 + "geometry" => array(),
  896 + "properties" => array(
  897 + $propriedades
  898 + ),
  899 + "geometry_name" => ""
909 900 )
910   - );
911   - }
912   - }
  901 + )
  902 + );
913 903 header("Content-type: application/json");
914   - echo json_encode($n[0]);
  904 + $json = json_encode($n[0]);
  905 + //verifica a substituicao de alias
  906 + $itens = $oMap->getlayer(0)->getmetadata("ITENS"); // itens
  907 + $itensdesc = $oMap->getlayer(0)->getmetadata("ITENSDESC"); // descrição dos itens
  908 + $itens = explode(",",$itens);
  909 + $itensdesc = explode(",",converteenc($itensdesc));
  910 + $n = count($itens);
  911 + for($i = 0; $i < $n; $i++){
  912 + $json = str_ireplace($itens[$i],$itensdesc[$i],$json);
  913 + }
  914 + echo $json;
915 915 exit;
916 916 }
917 917  
... ... @@ -1145,4 +1145,10 @@ function renderNocacheTms(){
1145 1145 header("Content-type: image/png");
1146 1146 }
1147 1147 }
  1148 +function converteenc($texto){
  1149 + if (!mb_detect_encoding($texto,"UTF-8",true)){
  1150 + $texto = mb_convert_encoding($texto,"UTF-8","ISO-8859-1");
  1151 + }
  1152 + return $texto;
  1153 +}
1148 1154 ?>
... ...
temas/_lbiomashp.map
... ... @@ -9,7 +9,7 @@ MAP
9 9 "TIP" "CD_LEGENDA"
10 10 "CLASSE" "SIM"
11 11 "permitekmz" "SIM"
12   - "ITENSDESC" "Teste de acentuação"
  12 + "ITENSDESC" "Bioma Teste de acentuação"
13 13 "ESCALA" "1000000"
14 14 "TILES" "SIM"
15 15 "METAESTAT_CODIGO_TIPO_REGIAO" ""
... ...