Commit 36987e22ba62c80574f250d06189bc996192ed22

Authored by Edmar Moretti
1 parent 23710609

Inclusão de matadata nos layers para controlar a conversão de caracteres

admin/js/editormapfile.js
... ... @@ -1349,6 +1349,8 @@ function montaEditorDados(dados)
1349 1349 "linhas":[
1350 1350 {ajuda:"Type of connection. Default is local.",
1351 1351 titulo:"Connectiontype",id:"",value:"",div:"<div id=cConnectiontype ></div>",tipo:"text"},
  1352 + {ajuda:"Aplica a conversão de caracteres nas ferramentas que obtém os dados descritivos referentes aos elementos do LAYER. Em alguns casos, a conversão pode provocar problemas de acentuação. Se isso ocorrer, na ferramenta tabela por exemplo, experimente marcar essa opção como 'nao'",
  1353 + titulo:"Conversão de caracteres (METADATA: CONVCARACTER)",id:"",value:dados.convcaracter,tipo:"text",div:"<div id=cConvcaracter ></div>"},
1352 1354 {ajuda:"Database connection string to retrieve remote data.An SDE connection string consists of a hostname, instance name, database name, username and password separated by commas.A PostGIS connection string is basically a regular PostgreSQL connection string, it takes the form of 'user=nobody password=****** dbname=dbname host=localhost port=5432' An Oracle connection string: user/pass[@db] . Se vc tiver problemas com acentuação, experimente algo como: user=postgres password=postgres dbname=pgutf8 host=localhost port=5432 options='-c client_encoding=LATIN1'",
1353 1355 titulo:"Connection",id:"connection",value:dados.connection,tipo:"text"},
1354 1356 {ajuda:"Full filename of the spatial data to process. No file extension is necessary for shapefiles. Can be specified relative to the SHAPEPATH option from the Map Object.If this is an SDE layer, the parameter should include the name of the layer as well as the geometry column, i.e. 'mylayer,shape,myversion'.If this is a PostGIS layer, the parameter should be in the form of '<columnname> from <tablename>', where 'columnname' is the name of the column containing the geometry objects and 'tablename' is the name of the table from which the geometry data will be read.For Oracle, use 'shape FROM table' or 'shape FROM (SELECT statement)' or even more complex Oracle compliant queries! Note that there are important performance impacts when using spatial subqueries however. Try using MapServer's FILTER whenever possible instead. You can also see the SQL submitted by forcing an error, for instance by submitting a DATA parameter you know won't work, using for example a bad column name. Exemplo postgis: the_geom FROM (select * FROM biomas) as foo USING UNIQUE gid USING SRID=4291 . Exemplo shapefile: c://ms4w/Apache/htdocs/geodados/brasil/limitespol/localidades.shp",
... ... @@ -1410,7 +1412,13 @@ function montaEditorDados(dados)
1410 1412 temp += core_comboObjeto(objlayertypes,"valor","texto",dados.type)
1411 1413 temp += "</select>"
1412 1414 $i("cType").innerHTML = temp
1413   -
  1415 +
  1416 + if($i("cConvcaracter")){
  1417 + temp = "<select id='convcaracter' >"
  1418 + temp += core_combosimnao(dados.convcaracter)
  1419 + temp += "</select>"
  1420 + $i("cConvcaracter").innerHTML = temp
  1421 + }
1414 1422  
1415 1423 var temp = function()
1416 1424 {salvarDadosEditor('conexao',dados.codigoMap,dados.codigoLayer,false)}
... ... @@ -1866,7 +1874,7 @@ function salvarDadosEditor(tipo,codigoMap,codigoLayer,indiceClasse,indiceEstilo,
1866 1874 }
1867 1875 if(tipo == "conexao")
1868 1876 {
1869   - var campos = new Array("cache","projection","type","connection","data","connectiontype","tileitem","tileindex","filteritem","filter","tipooriginal")
  1877 + var campos = new Array("cache","projection","type","connection","data","connectiontype","tileitem","tileindex","filteritem","filter","tipooriginal","convcaracter");
1870 1878 var par = "&codigoMap="+codigoMap+"&codigoLayer="+codigoLayer
1871 1879 var prog = "../php/editormapfile.php?funcao=alterarConexao"
1872 1880 }
... ...
admin/php/editormapfile.php
... ... @@ -1485,7 +1485,7 @@ function pegaConexao()
1485 1485 if($dados["projection"] == "null")
1486 1486 {$dados["projection"] = "";}
1487 1487 $dados["projection"] = str_replace("+i","i",$dados["projection"]);
1488   -
  1488 + $dados["convcaracter"] = $layer->getmetadata("convcaracter");
1489 1489 $dados["colunas"] = implode(" ,",pegaItens($layer));
1490 1490 if($layer->connectiontype == 7 || $layer->connectiontype == 9){
1491 1491 $dados["tipooriginal"] = $layer->getmetadata("tipooriginal");
... ... @@ -1494,7 +1494,7 @@ function pegaConexao()
1494 1494 }
1495 1495 function alterarConexao()
1496 1496 {
1497   - global $cache,$tipooriginal,$filteritem,$filter,$projection,$type,$dir_tmp,$testar,$codigoMap,$codigoLayer,$locaplic,$connection,$connectiontype,$data,$tileitem,$tileindex;
  1497 + global $convcaracter,$cache,$tipooriginal,$filteritem,$filter,$projection,$type,$dir_tmp,$testar,$codigoMap,$codigoLayer,$locaplic,$connection,$connectiontype,$data,$tileitem,$tileindex;
1498 1498 $mapfile = $locaplic."/temas/".$codigoMap.".map";
1499 1499 $mapa = ms_newMapObj($mapfile);
1500 1500 $layer = $mapa->getlayerbyname($codigoLayer);
... ... @@ -1516,7 +1516,8 @@ function alterarConexao()
1516 1516 if($layer->connectiontype == 7 || $layer->connectiontype== 9){
1517 1517 $layer->setmetadata("tipooriginal",$tipooriginal);
1518 1518 }
1519   - $layer->setmetadata("cache",$cache);
  1519 + $layer->setmetadata("cache",$cache);
  1520 + $layer->setmetadata("convcaracter",$convcaracter);
1520 1521 if($testar == "true")
1521 1522 {
1522 1523 $nome = $dir_tmp."/".$codigoMap.".map";
... ...
classesphp/classe_atributos.php
... ... @@ -275,13 +275,18 @@ $tipo - Tipo de busca brasil|null
275 275 $shapes = retornaShapesMapext($this->layer,$this->mapa);
276 276 }
277 277 $registros[] = array();
  278 + if(strtoupper($this->layer->getmetadata("convcaracter")) == "NAO")
  279 + {$convC = false;}
  280 + else
  281 + {$convC = true;}
278 282 foreach($shapes as $shape)
279 283 {
280 284 $valitem = array();
281 285 foreach ($items as $item)
282 286 {
283 287 $v = trim($shape->values[$item]);
284   - $v = $this->converte($v);
  288 + if($convC == true)
  289 + {$v = $this->converte($v);}
285 290 $valitem[] = $v;
286 291 }
287 292 $registros[] = implode(";",$valitem);
... ... @@ -335,6 +340,10 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona
335 340 $res_count = count($shapes);
336 341 $registros = array();
337 342 //lista apenas os selecionados
  343 + if(strtoupper($this->layer->getmetadata("convcaracter")) == "NAO")
  344 + {$convC = false;}
  345 + else
  346 + {$convC = true;}
338 347 if ($tipolista == "selecionados")
339 348 {
340 349 $chk = "CHECKED";
... ... @@ -350,7 +359,8 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona
350 359 foreach ($items as $item)
351 360 {
352 361 $valori = trim($shape->values[$item]);
353   - $valori = $this->converte($valori);
  362 + if($convC == true)
  363 + {$valori = $this->converte($valori);}
354 364 $valitem[] = array("item"=>$item,"valor"=>$valori);
355 365 }
356 366 $registros[] = array("indice"=>$indx,"valores"=>$valitem,"status"=>$chk);
... ... @@ -395,7 +405,8 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona
395 405 {
396 406 $valori = ($shape->values[$item]);
397 407 }
398   - $valori = $this->converte($valori);
  408 + if($convC == true)
  409 + {$valori = $this->converte($valori);}
399 410 $valitem[] = array("item"=>$item,"valor"=>$valori);
400 411 }
401 412 //if (in_array($shp_index,$shp_atual))
... ... @@ -460,6 +471,10 @@ $onde - Tipo de abrangência espacial (brasil ou mapa)
460 471 $this->layer = $l;
461 472 if ($l->data == "")
462 473 {return "Erro. O tema não tem tabela";}
  474 + if(strtoupper($this->layer->getmetadata("convcaracter")) == "NAO")
  475 + {$convC = false;}
  476 + else
  477 + {$convC = true;}
463 478 $filtro = $l->getfilterstring();
464 479 if ($filtro != ""){$l->setfilter("");}
465 480 $buscas = "ÁÃÓÕÔáàãâóòôõúûíéêç";
... ... @@ -481,7 +496,8 @@ $onde - Tipo de abrangência espacial (brasil ou mapa)
481 496 {
482 497 if (strtr($v,$buscas,$trocas) == strtr($palavra,$buscas,$trocas))
483 498 {
484   - $v = $this->converte($v);
  499 + if($convC == true)
  500 + {$v = $this->converte($v);}
485 501 $r[] = array("item" => $item,"valor" => $v);
486 502 $encontrado = "sim";
487 503 }
... ... @@ -490,7 +506,8 @@ $onde - Tipo de abrangência espacial (brasil ou mapa)
490 506 {
491 507 if (stristr(strtr($v,$buscas,$trocas),strtr($palavra,$buscas,$trocas)))
492 508 {
493   - $v = $this->converte($v);
  509 + if($convC == true)
  510 + {$v = $this->converte($v);}
494 511 $r[] = array("item" => $item,"valor" => $v);
495 512 $encontrado = "sim";
496 513 }
... ... @@ -1163,6 +1180,10 @@ $listaDeTemas - (opcional) Lista com os códigos dos temas que serão identificado
1163 1180 $layer->set("template","none.htm");
1164 1181 $pt = ms_newPointObj();
1165 1182 $pt->setXY($x, $y);
  1183 + if(strtoupper($layer->getmetadata("convcaracter")) == "NAO")
  1184 + {$convC = false;}
  1185 + else
  1186 + {$convC = true;}
1166 1187 //
1167 1188 //operação especial para o caso de wms
1168 1189 //
... ... @@ -1216,7 +1237,8 @@ $listaDeTemas - (opcional) Lista com os códigos dos temas que serão identificado
1216 1237 if(trim($v) != "")
1217 1238 {
1218 1239 $va = trim($v);
1219   - $va = $this->converte($va);
  1240 + if($convC == true)
  1241 + {$va = $this->converte($va);}
1220 1242 $n[] = array("alias"=>trim($t[0]),"valor"=>$va,"link"=>"","img"=>"");
1221 1243 }
1222 1244 }
... ... @@ -1232,7 +1254,10 @@ $listaDeTemas - (opcional) Lista com os códigos dos temas que serão identificado
1232 1254 $linha = explode("|",$linha);
1233 1255 for($i=0;$i < count($cabecalho);++$i)
1234 1256 {
1235   - $va = $this->converte($linha[$i]);
  1257 + if($convC == true)
  1258 + {$va = $this->converte($linha[$i]);}
  1259 + else
  1260 + {$va = $linha[$i];}
1236 1261 $n[] = array("alias"=>$cabecalho[$i],"valor"=>$va,"link"=>"","img"=>"");
1237 1262 }
1238 1263 }
... ... @@ -1320,6 +1345,10 @@ $listaDeTemas - (opcional) Lista com os códigos dos temas que serão identificado
1320 1345 $ident = @$layer->queryByPoint($pt, 1, -1);
1321 1346 $sopen = $layer->open();
1322 1347 $res_count = $layer->getNumresults();
  1348 + if(strtoupper($layer->getmetadata("convcaracter")) == "NAO")
  1349 + {$convC = false;}
  1350 + else
  1351 + {$convC = true;}
1323 1352 if($sopen == MS_FAILURE){return "erro";}
1324 1353 for ($i = 0; $i < $res_count; ++$i)
1325 1354 {
... ... @@ -1355,6 +1384,8 @@ $listaDeTemas - (opcional) Lista com os códigos dos temas que serão identificado
1355 1384 foreach ($itens as $it)
1356 1385 {
1357 1386 $val = $shape->values[$it];
  1387 + if($convC == true)
  1388 + {$val = $this->converte($val);}
1358 1389 $link = $lks[$conta];
1359 1390 foreach($itens as $t)
1360 1391 {
... ... @@ -1374,7 +1405,7 @@ $listaDeTemas - (opcional) Lista com os códigos dos temas que serão identificado
1374 1405 {$etiqueta = "sim";}
1375 1406 $arraytemp = array(
1376 1407 "alias"=>$this->converte($itensdesc[$conta]),
1377   - "valor"=>$this->converte($val),
  1408 + "valor"=>$val,
1378 1409 "link"=>$link,
1379 1410 "img"=>$img,
1380 1411 "tip"=>$etiqueta
... ...
ferramentas/tabela/relatorio.php
... ... @@ -50,6 +50,10 @@ if ($layer-&gt;getNumresults() &gt; 0){$existesel = &quot;sim&quot;;}
50 50 if ($existesel == "nao")
51 51 {$layer->querybyrect($mapa->extent);}
52 52 $layer->open();
  53 +if(strtoupper($layer->getmetadata("convcaracter")) == "NAO")
  54 +{$convC = false;}
  55 +else
  56 +{$convC = true;}
53 57 //$registros[] = array();
54 58 $res_count = $layer->getNumresults();
55 59 for ($i = 0; $i < $res_count; $i++)
... ... @@ -62,7 +66,7 @@ for ($i = 0; $i &lt; $res_count; $i++)
62 66 foreach ($itensrel as $item)
63 67 {
64 68 $v = trim($shape->values[$item]);
65   - if (function_exists("mb_convert_encoding"))
  69 + if (function_exists("mb_convert_encoding") && $convC == true)
66 70 {$v = mb_convert_encoding($v,"UTF-8","ISO-8859-1");}
67 71 $valitem[$item] = $v;
68 72 }
... ...
ms_configura.php
... ... @@ -312,7 +312,7 @@ if (strtoupper(substr(PHP_OS, 0, 3) == &#39;WIN&#39;))
312 312 */
313 313 $postgis_mapa = array(
314 314 "teste"=>"user=postgres password=postgres dbname=postgis host=localhost port=5432 options='-c client_encoding=LATIN1'",
315   - "postgres"=>"user=postgres password=postgres dbname=postgis host=localhost port=5432'",
  315 + "postgres"=>"user=postgres password=postgres dbname=postgis host=localhost port=5432",
316 316 ); //"user=geodados password=geodados dbname=geodados host=10.1.1.36 port=5432";
317 317 /*
318 318 Variable: utilizacgi
... ...
temas/testeutf8postgis.map
1   -MAP
2   -
3   -
4   - FONTSET "../symbols/fontes.txt"
5   - SYMBOLSET "../symbols/simbolos.sym"
  1 +MAP
  2 + FONTSET "../symbols/fontes.txt"
  3 + SYMBOLSET "../symbols/simbolos.sym"
6 4 LAYER
7   - #CONNECTION "teste"
8   - CONNECTION "user=postgres password=postgres dbname=postgis host=localhost port=5432 options='-c client_encoding=ISO-8859-1'"
  5 + CONNECTION "teste"
9 6 CONNECTIONTYPE POSTGIS
10 7 DATA "the_geom FROM (select * FROM teste.estados) as foo USING UNIQUE gid USING SRID=4291"
11 8 METADATA
  9 + "cache" ""
12 10 "CLASSE" "SIM"
13 11 "permitekmz" ""
14 12 "permitedownload" ""
15 13 "download" "SIM"
16   - "permitekml" "sim"
17 14 "permiteogc" "sim"
  15 + "permitekml" "sim"
  16 + "convcaracter" "SIM"
18 17 "TEMA" "Teste UTF8 Postgis"
19 18 END
20 19 NAME "testeutf8postgis"
... ... @@ -27,9 +26,11 @@ MAP
27 26 STYLE
28 27 ANGLE 360
29 28 COLOR 196 185 103
30   - OPACITY 100
31 29 SYMBOL 0
  30 + WIDTH 1
32 31 END
33 32 END
34 33 END
  34 +
35 35 END
  36 +
... ...
testamapfile.php
... ... @@ -136,7 +136,7 @@ function verifica($map,$solegenda)
136 136 $tema = "";
137 137  
138 138 if(file_exists($map))
139   - $tema = $map;
  139 + {$tema = $map;}
140 140 else
141 141 {
142 142 $map = str_replace("\\","/",$map);
... ... @@ -151,6 +151,8 @@ function verifica($map,$solegenda)
151 151 if(($tipo == "") || ($tipo == "todos"))
152 152 {echo "<hr><br><br><span style='color:red' ><b>Testando: $tema </span><pre></b>";}
153 153 if(!file_exists($tema))
  154 + {$tema = $locaplic."/".$tema;}
  155 + if(!file_exists($tema))
154 156 {echo "Arquivo ".$map." não encontrado.";exit;}
155 157 if ($tema != "")
156 158 {
... ... @@ -189,13 +191,14 @@ function verifica($map,$solegenda)
189 191 eval($pegarext."(\$mapa);");
190 192 }
191 193 else{
192   - if(@ms_newMapObj($locaplic."/".$tema))
  194 + if(@ms_newMapObj($tema))
193 195 {
194   - $nmapa = ms_newMapObj($locaplic."/".$tema);
  196 + $nmapa = ms_newMapObj($tema);
195 197 }
196 198 else
197 199 {
198 200 echo "erro no arquivo $map <br>";
  201 + echo "Obs.: em alguns testes o mapfile pode falhar se o endereço dos arquivos de símbolos estiverem <br>definidos de forma relativa ao invés de absoluta. Nesses casos, ao abrir o i3Geo, <br>o mapfile poderá funcionar. <br>";
199 202 $error = ms_GetErrorObj();
200 203 while($error && $error->code != MS_NOERR)
201 204 {
... ...