classe_escala.php
7.8 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
/*
* Title: classe_escala.php
*
* Manipulação da escala.
*
* Cria escala grafica, edita características, etc.
*
* Licenca:
*
* GPL2
*
*
* i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
*
* Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil
* Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com
*
* Este programa é software livre; você pode redistribuí-lo
* e/ou modificá-lo sob os termos da Licença Pública Geral
* GNU conforme publicada pela Free Software Foundation;
*
* Este programa é distribuído na expectativa de que seja útil,
* porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita
* de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA.
* Consulte a Licença Pública Geral do GNU para mais detalhes.
* Você deve ter recebido uma c�pia da Licença Pública Geral do
* GNU junto com este programa; se não, escreva para a
* Free Software Foundation, Inc., no endereço
* 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
*
* Arquivo:
*
* i3geo/classesphp/classe_escala.php
*/
/*
* Classe: Escala
*/
class Escala
{
/*
* Variavel: $mapa
*
* Objeto mapa
*/
protected $mapa;
/*
* Variavel: $arquivo
*
* Arquivo map file
*/
protected $arquivo;
/*
* Variavel: $nomeImagem
*
* Nome da imagem criada
*/
protected $nomeImagem;
/*
* function: __construct
*
* Cria um objeto Escala
*
* parameters:
* $map_file - Endereço do mapfile no servidor.
*/
function __construct($map_file, $nomeImagem = "", $locaplic = "", $mapexten = "")
{
include (dirname(__FILE__) . "/../ms_configura.php");
$this->postgis_mapa = $postgis_mapa;
if (file_exists($locaplic . "/funcoes_gerais.php"))
include_once ($locaplic . "/funcoes_gerais.php");
else
include_once ("funcoes_gerais.php");
$this->locaplic = $locaplic;
$this->mapa = ms_newMapObj($map_file);
substituiConObj($this->mapa, $postgis_mapa);
$this->arquivo = str_replace(".map", "", $map_file) . ".map";
if ($nomeImagem == "") {
$this->nomeImagem = nomeRandomico();
}
if ($mapexten != "") {
$ext = explode(" ", $mapexten);
$extatual = $this->mapa->extent;
$extatual->setextent($ext[0], $ext[1], $ext[2], $ext[3]);
}
}
/*
* function: salva
*
* Salva o mapfile atual
*
*/
function salva()
{
restauraConObj($this->mapa, $this->postgis_mapa);
$this->mapa->save($this->arquivo);
}
/*
* function: retornaBarraEscala
*
* Gera barra de escala.
*
* Retorna uma string com sintaxe em javaScript com o nome da imagem e demais parâmetros.
*
* return:
* string com variáveis javascript.
*/
function retornaBarraEscala()
{
$this->mapa->preparequery();
$objImagem = $this->mapa->drawscalebar();
if ($objImagem->imagepath == "") {
echo "Erro IMAGEPATH vazio";
exit();
}
$nomer = ($objImagem->imagepath) . "sca" . $this->nomeImagem . ".png";
$objImagem->saveImage($nomer);
$nomer = ($objImagem->imageurl) . basename($nomer);
return (array(
"scaimagem" => $nomer,
"scawidth" => $objImagem->width,
"scaheight" => $objImagem->height,
"scapath" => $objImagem->imagepath,
"scaurl" => $objImagem->imageurl
));
}
/*
* function: parametrosBarraEscala
*
* Pega os parâmetros da barra de escala.
*
* return:
* string javascript com os parametros.
*/
function parametrosBarraEscala()
{
$eb = $this->mapa->scalebar;
$cor = $eb->color;
$fcor = $cor->red . "," . $cor->green . "," . $cor->blue;
$cor = $eb->backgroundcolor;
$bcor = $cor->red . "," . $cor->green . "," . $cor->blue;
$cor = $eb->outlinecolor;
$ocor = $cor->red . "," . $cor->green . "," . $cor->blue;
return (array(
"color" => $fcor,
"backgroundcolor" => $bcor,
"outlinecolor" => $ocor,
"status" => $eb->status,
"width" => $eb->width,
"height" => $eb->height,
"style" => $eb->style,
"intervals" => $eb->intervals,
"units" => $eb->units
));
}
/*
* array("color"=>"","backgroundcolor"=>"","outlinecolor"=>"","status"=>"","width"=>"","height"=>"","style"=>"","intervals"=>"","units"=>"")
*/
function mudaEscalaGrafica($parameters = array("color"=>"","backgroundcolor"=>"","outlinecolor"=>"","status"=>"","width"=>"","height"=>"","style"=>"","intervals"=>"","units"=>""))
{
$eb = $this->mapa->scalebar;
$eb->set("width", $parameters["width"]);
$eb->set("height", $parameters["height"]);
if ($parameters["style"] != 2) {
$eb->set("style", $parameters["style"]);
}
$eb->set("intervals", $parameters["intervals"]);
$eb->set("units", $parameters["units"]);
$corn = $eb->color;
$n = explode(",", $parameters["color"]);
$corn->setrgb($n[0], $n[1], $n[2]);
$cornb = $eb->backgroundcolor;
$n = explode(",", $parameters["backgroundcolor"]);
$cornb->setrgb($n[0], $n[1], $n[2]);
$corno = $eb->outlinecolor;
$n = explode(",", $parameters["outlinecolor"]);
$corno->setrgb($n[0], $n[1], $n[2]);
// desabilita a escala
if ($parameters["style"] == 2) {
$eb->set("status", MS_OFF);
} else {
$eb->set("status", MS_EMBED);
}
if ($parameters["status"] == 3) {
$eb->set("status", MS_EMBED);
} // MS_ON, MS_OFF, MS_EMBED
else {
$eb->set("status", MS_OFF);
}
$this->salva();
return ("ok");
}
/*
* array("color"=>"","backgroundcolor"=>"","outlinecolor"=>"","status"=>"","width"=>"","height"=>"","style"=>"","intervals"=>"","units"=>"")
*/
function testaescalagrafica($parameters = array("color"=>"","backgroundcolor"=>"","outlinecolor"=>"","status"=>"","width"=>"","height"=>"","style"=>"","intervals"=>"","units"=>""))
{
$eb = $this->mapa->scalebar;
$eb->set("width", $parameters["width"]);
$eb->set("height", $parameters["height"]);
if ($parameters["style"] != 2) {
$eb->set("style", $parameters["style"]);
}
$eb->set("intervals", $parameters["intervals"]);
$eb->set("units", $parameters["units"]);
$corn = $eb->color;
$n = explode(",", $parameters["color"]);
$corn->setrgb($n[0], $n[1], $n[2]);
$cornb = $eb->backgroundcolor;
$n = explode(",", $parameters["backgroundcolor"]);
$cornb->setrgb($n[0], $n[1], $n[2]);
$corno = $eb->outlinecolor;
$n = explode(",", $parameters["outlinecolor"]);
$corno->setrgb($n[0], $n[1], $n[2]);
// desabilita a escala
if ($parameters["style"] == 2) {
$eb->set("status", MS_OFF);
} else {
$eb->set("status", MS_EMBED);
}
if ($parameters["status"] == 3) {
$eb->set("status", MS_EMBED);
} // MS_ON, MS_OFF, MS_EMBED
else {
$eb->set("status", MS_OFF);
}
$objImagem = $this->mapa->drawscalebar();
$nomer = ($objImagem->imagepath) . "sca" . $this->nomeImagem . ".png";
$objImagem->saveImage($nomer);
$nomer = ($objImagem->imageurl) . basename($nomer);
return ($nomer);
}
}
?>