funcoes.php
4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
namespace admin\catalogo\mapfile\conexao\local;
function listar($locaplic, $codigo) {
// pega o nome registrado no mapfile
if (! file_exists ( $locaplic . "/temas/" . $codigo . ".map" )) {
header ( "HTTP/1.1 500 erro mapfile nao existe" );
exit ();
}
$mapa = ms_newMapObj ( $locaplic . "/temas/" . $codigo . ".map" );
$layer = $mapa->getlayerbyname ( $codigo );
if ($layer == "") {
header ( "HTTP/1.1 500 erro nao existe LAYER com o nome $codigo" );
exit ();
}
$dados = array ();
$dados ["connection"] = $layer->connection;
$dados ["connectiontype"] = $layer->connectiontype;
$dados ["data"] = $layer->data;
$dados ["tileindex"] = $layer->tileindex;
$dados ["tileitem"] = $layer->tileitem;
if ($dados ["tileindex"] == "") {
$dados ["tileitem"] = "";
}
if (is_array ( $postgis_mapa )) {
$dados ["postgis_mapa"] = array_keys ( $postgis_mapa );
} else {
$dados ["postgis_mapa"] = $postgis_mapa;
}
$dados ["type"] = $layer->type;
$dados ["projection"] = $layer->getProjection ();
if ($dados ["projection"] == "null") {
$dados ["projection"] = "";
}
$dados ["projection"] = str_replace ( "+i", "i", $dados ["projection"] );
$dados ["convcaracter"] = $layer->getmetadata ( "convcaracter" );
if(empty($dados ["convcaracter"])){
$dados ["convcaracter"] = "NAO";
}
$dados ["convcaracter"] = strtoupper($dados ["convcaracter"]);
// informacoes sobre a integracao com o sistema de metadados estatisticos
$dados ["metaestat"] = $layer->getmetadata ( "metaestat" );
if ($dados ["metaestat"] == "") {
$dados ["metaestat"] = "NAO";
}
$dados ["metaestat"] = strtoupper($dados ["metaestat"]);
$dados ["metaestat_id_medida_variavel"] = $layer->getmetadata ( "metaestat_id_medida_variavel" );
return $dados;
}
function alterar($locaplic,$codigo,$connection,$connectiontype,$data,$tileindex,$tileitem,$type,$projection,$convcaracter,$metaestat,$metaestat_id_medida_variavel,$dbhw) {
$esquemaadmin = $_SESSION["esquemaadmin"];
$arq = $locaplic . "/temas/" . $codigo . ".map";
if ($codigo == "" || ! file_exists ( $arq )) {
header ( "HTTP/1.1 400 arquivo nao existe" );
exit ();
}
$mapa = ms_newMapObj ( $arq );
$layer = @$mapa->getlayerbyname ( $codigo );
if ($layer == "") {
return false;
}
if(strtoupper($metaestat) == "SIM"){
if(empty($metaestat_id_medida_variavel)){
header ( "HTTP/1.1 400 id da medida esta vazio" );
exit ();
}
$connectiontype = 6;
$filteritem = "";
$filter = "";
$data = "";
$connection = "";
$dataCol = array(
"tipoa_tema" => "META"
);
\admin\php\funcoesAdmin\i3GeoAdminUpdate($dbhw,"i3geoadmin_temas",$dataCol,"WHERE codigo_tema = '$codigo'");
$layer->setmetadata("metaestat","SIM");
$layer->setmetadata("METAESTAT_ID_MEDIDA_VARIAVEL",$metaestat_id_medida_variavel);
}
else{
$layer->setmetadata("METAESTAT_CODIGO_TIPO_REGIAO","");
$layer->setmetadata("METAESTAT_ID_MEDIDA_VARIAVEL","");
$layer->setmetadata("metaestat","");
$dataCol = array(
"tipoa_tema" => ""
);
\admin\php\funcoesAdmin\i3GeoAdminUpdate($dbhw,"i3geoadmin_temas",$dataCol,"WHERE codigo_tema = '$codigo'");
}
//verifica a simbologia
//evita que o LAYER falhe ao ser testado por nao ter o simbolo definido
if($type == 0){
$c = $layer->getClass(0);
$e = $c->getStyle(0);
if($e->symbolname == ""){
$e->set("symbolname","ponto");
}
}
if($type == 1){
$c = $layer->getClass(0);
$e = $c->getStyle(0);
if($e->symbolname == "" || $e->symbolname == "ponto"){
$e->set("symbolname","linha");
}
}
if($type == 2){
$c = $layer->getClass(0);
$e = $c->getStyle(0);
if($e->symbolname == "linha" || $e->symbolname == "ponto"){
$e->set("symbolname"," ");
}
}
$layer->setmetadata("convcaracter",$convcaracter);
$layer->set("connection",$connection);
$layer->setconnectiontype($connectiontype);
$layer->set("data",$data);
$layer->set("tileitem",$tileitem);
$layer->set("tileindex",$tileindex);
$layer->set("type",$type);
$layer->setfilter($filter);
$layer->set("filteritem",$filteritem);
if($layer->getprojection() == MS_TRUE){
$layer->setprojection($projection);
if($layer->getprojection() == MS_FALSE && $projection != ""){
$layer->setprojection($projection);
}
}
try {
$mapa->save ( $arq );
\admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq );
return true;
} catch ( Exception $e ) {
return false;
}
}
?>