classe_legenda.php
21.5 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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
<?php
/*
Title: classe_legenda.php
Manipulação da legenda.
Cria legenda, edita simbolos, 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@mma.gov.br
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_legenda.php
*/
/*
Classe: Legenda
*/
class Legenda
{
/*
Variavel: $mapa
Objeto mapa
*/
protected $mapa;
/*
Variavel: $arquivo
Arquivo map file
*/
protected $arquivo;
/*
Variavel: $layer
Objeto layer
*/
protected $layer;
/*
Variavel: $nome
Nome do layer
*/
protected $nome;
/*
Variavel: $grupo
Array com os temas do grupo, se houver
*/
protected $grupo;
/*
Variavel: $visiveis
Temas do grupo que são visíveis em função da escala
*/
protected $visiveis;
/*
Variavel: $indices
Indices dos layers do grupo
*/
protected $indices;
/*
Variavel: $templateleg
Template da legenda
*/
protected $templateleg;
/*
Variavel: $localaplicacao
Localização da aplicação
*/
protected $localaplicacao;
/*
Function: __construct
Cria um objeto Legenda
parameters:
$map_file - Endereço do mapfile no servidor.
$locaplic - localização do I3Geo no servidor
$tema - nome do tema
$template - nome do template para processar a legenda
*/
function __construct($map_file="",$locaplic="",$tema="",$template="")
{
//error_reporting(E_ALL);
if(file_exists($locaplic."/funcoes_gerais.php"))
include_once($locaplic."/funcoes_gerais.php");
else
include_once("funcoes_gerais.php");
$this->localaplicacao = $locaplic;
if($map_file == "")
{return;}
$this->mapa = ms_newMapObj($map_file);
$this->arquivo = $map_file;
if($tema != "" && @$this->mapa->getlayerbyname($tema))
{
$this->layer = $this->mapa->getlayerbyname($tema);
$this->nome = $tema;
$vermultilayer = new vermultilayer();
$vermultilayer->verifica($map_file,$tema);
if ($vermultilayer->resultado == 1) // o tema e multi layer
{
$ls = $vermultilayer->temas;
$this->visiveis = $vermultilayer->temasvisiveis;
}
else
{
$ls[] = $tema;
$this->visiveis = array($tema);
}
$this->grupo = $ls;
foreach ($ls as $l)
{
$t = $this->mapa->getlayerbyname($l);
$this->indices[] = $t->index;
}
}
if ($template == ""){$template="legenda.htm";}
if(file_exists($template))
{
$this->templateleg = $template;
return;
}
if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))
{$this->templateleg = $locaplic."\\aplicmap\\".$template;}
else
{$this->templateleg = $locaplic."/aplicmap/".$template;}
}
/*
function: salva
Salva o mapfile atual
*/
function salva()
{
if (connection_aborted()){exit();}
$this->recalculaSLD();
$this->mapa->save($this->arquivo);
}
/*
function: recalculaSLD
Constrói o SLD que é aplicado ao metadata wms_sld_body. O SLD resultante é baseado nas definições das classes existentes no layer
*/
function recalculaSLD(){
if($this->layer->classitem != "" && $this->layer->connectiontype == 7 && $this->layer->numclasses > 0){
$tipotemp = $this->layer->type;
$tiporep = $this->layer->getmetadata("tipooriginal");
$this->layer->set("type",MS_LAYER_POLYGON);
if ($tiporep == "linear")
{$this->layer->set("type",MS_LAYER_LINE);}
if ($tiporep == "pontual")
{$this->layer->set("type",MS_LAYER_POINT);}
$this->layer->set("status",MS_DEFAULT);
$this->layer->setmetadata("wms_sld_body","");
$sld = $this->layer->generateSLD();
if($sld != "")
{$this->layer->setmetadata("wms_sld_body",str_replace('"',"'",$sld));}
$this->layer->set("type",$tipotemp);
}
}
/*
function: criaLegenda
Gera a legenda processando o template HTML definido na construção da classe.
Se o tema for um WMS ou se o metadata legendaimg estiver definido, executa $this->tabelaLegenda
Return:
string com a legenda HTML
*/
function criaLegenda()
{
$l = "";
$numlayers = $this->mapa->numlayers;
if($this->nome != "")
{
//verifica se é wms ou se o metadata legendaimg está definido
$c = $this->layer->connectiontype;
if ($c == 7 || $this->layer->getmetadata("legendaimg") != "")
{
return($this->tabelaLegenda());
}
for ($i=0;$i < $numlayers;++$i)
{
$la = $this->mapa->getlayer($i);
if ($la->name != $this->nome)
{$la->set("status",MS_OFF);}
if ($la->group == $this->nome)
{$la->set("status",MS_DEFAULT);}
}
$this->layer->set("status",MS_DEFAULT);
}
$desligar = array();
$conta = 0;
$desligar = array();
for ($i=0;$i < $numlayers;++$i)
{
$la = $this->mapa->getlayer($i);
if (strtoupper($la->getmetadata("ESCONDIDO")) == "SIM")
{$la->set("status",MS_OFF);}
if($la->status == MS_DEFAULT)
{
$nc = $la->numclasses;
for ($c = 0;$c < $nc;$c++)
{
$classe = $la->getclass($c);
if($classe->status == MS_OFF)
{$desligar[] = $conta;}
$conta = $conta + 1;
}
}
}
$legenda = $this->mapa->legend;
$legenda->set("template",$this->templateleg);
$tmparray["my_tag"] = "value_of_my_tag";
if(!$l = @$this->mapa->processlegendtemplate($tmparray))
{return ("erro");}
if (function_exists("mb_convert_encoding"))
{$l = mb_convert_encoding($l,"UTF-8","ISO-8859-1");}
return (array("legenda"=>$l,"desativar"=>$desligar));
}
/*
function: legendaGrafica
Desenha a imagem da legenda.
return:
string de variaveis no formato javascript que permitem montar a legenda.
*/
function legendaGrafica()
{
$nomeslayers = $this->mapa->getalllayernames();
foreach ($nomeslayers as $nomelayer)
{
$layer = $this->mapa->getlayerbyname($nomelayer);
if (($layer->data != "") && (strtoupper($layer->getmetadata("escondido")) != "SIM") && (strtoupper($layer->getmetadata("tema")) != "NAO"))
{
if ($layer->numclasses > 0)
{
$classe = $layer->getclass(0);
if (($classe->name == "") || ($classe->name == " "))
{$classe->set("name",$layer->getmetadata("tema"));}
}
}
}
$nomeImagem = nomeRandomico();
$imgo = $this->mapa->drawlegend();
$nomer = ($imgo->imagepath)."leg".$nomeImagem.".png";
$imgo->saveImage($nomer);
$nomer = ($imgo->imageurl).basename($nomer);
return("var legimagem='".$nomer."';var legwidth=".$imgo->width.";var legheight=".$imgo->height.";var legpath='".$imgo->imagepath."';var legurl='".$imgo->imageurl."'");
}
/*
function: tabelaLegenda
Cria elementos para construir uma legenda no formato de tabela em HTML.
Utilizado na função de edição de legenda e legenda de WMS
parameters:
totaliza - sim|nao indica se os totais de elementos devem ser acrescentados ao nome da classe
return:
array
*/
function tabelaLegenda($totaliza="nao")
{
$linhas = array();
foreach ($this->visiveis as $l)
{
$layer = $this->mapa->getlayerbyname($l);
//verifica se é wms ou wfs
$c = $layer->connectiontype;
$s = $layer->getmetadata("wms_sld_url");
$im = $layer->getmetadata("legendaimg");
$nc = $layer->numclasses;
//
//se for wms e tiver classes define o tipo de layer para poder gerar a legenda corretamente
//
if($c == 7 && $nc > 0){
$tipotemp = $layer->type;
$tiporep = $layer->getmetadata("tipooriginal");
$layer->set("type",MS_LAYER_POLYGON);
if($tiporep == "linear")
{$layer->set("type",MS_LAYER_LINE);}
if ($tiporep == "pontual")
{$layer->set("type",MS_LAYER_POINT);}
}
//
//se for WMS e não tiver classes, tenta pegar a legenda via requisição WMS
//
if ($nc == 0 && ($c == 7 || $im != ""))
{
if($c == 7){
$con = $layer->connection;
$ver = $layer->getmetadata("wms_server_version");
$lwms = $layer->getmetadata("wms_name");
$f = $layer->getmetadata("wms_formatlist");
$f = explode(",",$f);
$f = $f[0];
$imgLeg = $con."&request=GetLegendGraphic&version=".$ver."&service=wms&layer=".$lwms."&format=".$f."&SLD=".$s;
if ($layer->getmetadata("legendawms") != "")
{$imgLeg = $layer->getmetadata("legendawms");}
}
else
{$imgLeg = $im;}
$linhas[] = array("tema"=>$l,"idclasse"=>"","nomeclasse"=>"","expressao"=>"","expressao"=>"","imagem"=>$imgLeg);
}
else
{
for ($c = 0;$c < $nc;$c++)
{
$classe = $layer->getclass($c);
$imgi = $classe->createlegendicon(30,15);
$classe->drawlegendicon(30,15,$imgi,5,5);
$nomes = nomeRandomico(12);
$nomer = ($imgi->imagepath)."icone".$nomes.".png";
$imgi->saveImage($nomer);
$i = ($imgi->imageurl).basename($nomer);
$nomeclasse = $classe->name;
if (function_exists("mb_convert_encoding"))
{$nomeclasse = mb_convert_encoding($nomeclasse,"UTF-8","ISO-8859-1");}
$nomeexp = $classe->getExpressionString();
if (function_exists("mb_convert_encoding"))
{$nomeexp = mb_convert_encoding($nomeexp,"UTF-8","ISO-8859-1");}
$linhas[] = array("tema"=>$l,"idclasse"=>$c,"nomeclasse"=>$nomeclasse,"expressao"=>$nomeexp,"imagem"=>$i,"proc"=>"");
}
if (($totaliza=="sim") && ($nc > 1))
{
$layer->set("template","none.htm");
$sopen = $layer->open();
if($sopen == MS_FAILURE){return "erro";}
$itens = $layer->getitems();
$total = 0;
$nreg = array();
for ($c = 0;$c < $nc;$c++)
{
$exp = $linhas[$c]["expressao"];
if($exp !== "")
{
if($this->layer->connectiontype == MS_POSTGIS)
{
$exp = str_replace("eq"," = ",$exp);
$exp = str_replace("ne"," != ",$exp);
$exp = str_replace("lt"," < ",$exp);
$exp = str_replace("gt"," < ",$exp);
$exp = str_replace("(","",$exp);
$exp = str_replace(")","",$exp);
$exp = str_replace("'[","",$exp);
$exp = str_replace("]'","",$exp);
$exp = str_replace("' [","",$exp);
$exp = str_replace("] '","",$exp);
$exp = str_replace("and"," and ",$exp);
$exp = str_replace("or"," or ",$exp);
$exp = str_replace("[","",$exp);
$exp = str_replace("]","",$exp);
}
$teste = $layer->queryByAttributes($itens[0], $exp, 1);
}
else
{$teste = 0;}
if ($teste == 0)
{
$n = $layer->getNumResults();
$nreg[] = $n;
}
else {$nreg[] = "erro";}
$total = $total + $n;
}
$layer->close();
for ($c = 0;$c < $nc;$c++)
{
$linhas[$c]["nomeclasse"] = $linhas[$c]["nomeclasse"]." - n=".$nreg[$c]."(".(round(($nreg[$c] * 100 / $total)))."%)";
$linhas[$c]["nreg"] = $nreg[$c];
$linhas[$c]["totalreg"] = $total;
}
}
if ($layer->type == MS_LAYER_RASTER && $nc == 1)
{
$proc = "";
$linhas = array();
if($layer->num_processing > 0){$proc = $layer->getProcessing();}
if($layer->type == MS_LAYER_RASTER && $proc == "")
{
$proc = array("RESAMPLE=NEAREST");
}
$linhas[] = array("tema"=>$l,"idclasse"=>"","nomeclasse"=>"","expressao"=>"","imagem"=>"","proc"=>$proc);
}
}
}
return $linhas;
}
/*
function: excluiEstilo
Exclui um estilo de uma classe.
*/
function excluiEstilo($classe,$estilo)
{
if(!$this->layer){return "erro";}
$classe = $this->layer->getclass($classe);
$classe->deletestyle($estilo);
$this->layer->removeMetaData("cache");
}
/*
function: adicionaEstilo
Adiciona um estilo em uma classe.
return:
objeto estilo
*/
function adicionaEstilo($classe,$estilo)
{
if(!$this->layer){return "erro";}
$classe = $this->layer->getclass($classe);
$estilo = $classe->getstyle($estilo);
$e = ms_newStyleObj($classe,$estilo);
$this->layer->removeMetaData("cache");
return($e);
}
/*
function: sobeEstilo
Sobe um estilo na ordem de desenho de uma classe.
parameters:
$classe - Índice da classe.
$estilo - Índice do estilo de uma classe que será clonado.
*/
function sobeEstilo($classe,$estilo)
{
if(!$this->layer){return "erro";}
$classe = $this->layer->getclass($classe);
$classe->movestyleup($estilo);
$this->layer->removeMetaData("cache");
}
/*
function: desceEstilo
Desce um estilo na ordem de desenho de uma classe.
parameters:
$classe - Índice da classe.
$estilo - Índice do estilo de uma classe que será clonado.
*/
function desceEstilo($classe,$estilo)
{
if(!$this->layer){return "erro";}
$classe = $this->layer->getclass($classe);
$classe->movestyledown($estilo);
$this->layer->removeMetaData("cache");
}
/*
function: listaSimbolos
Retorna uma lista de símbolos clicáveis no formato HTML.
Para cada tipo de simbologia deve haver um arquivo .map com as definições básicas.
Todos os símbolos do arquivo symbols/simbolos serão retornados como imagens.
parameters:
$tipo - Tipo de representação do símbolo, 0 pontos, 1 linhas e 2 polígonos.
$dir_tmp - Diretório temporário do mapserver.
$imgdir - Diretório temporário das imagens.
$onclick - Função que será incluída no HTML no evento onclick sobre o símbolo
$tamanho - Tamanho (size) do símbolo
return:
String no formato HTML com as imagens dos símbolos
*/
function listaSimbolos($tipo,$dir_tmp,$imgdir,$onclick,$tamanho=8,$width=1)
{
//error_reporting(E_ALL);
if ($tipo == 3){$tipo = 2;} //tipo raster
if($imgdir == "")
{$dir = $dir_tmp;}
else
{$dir = $dir_tmp."/".$imgdir;}
if (!file_exists($dir."/simbolos".$tipo.".inc"))
{
$f = fopen($dir."/simbolos".$tipo.".inc","w");
if ($tipo == 2){$t="simpol.map";}
if ($tipo == 0){$t="simpt.map";}
if ($tipo == 1){
$t="simlin.map";
$tamanho = $tamanho / 4;
}
if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))
{$mapatemp = ms_newMapObj($this->localaplicacao."\\aplicmap\\".$t);}
else
{$mapatemp = ms_newMapObj($this->localaplicacao."/aplicmap/".$t);}
$ins = "";
$ns = $mapatemp->getnumsymbols();
$l = $mapatemp->getlayer(0);
$novoss = dirname($this->mapa->symbolsetfilename)."/".basename($mapatemp->symbolsetfilename);
$this->mapa->setsymbolset($novoss);
for ($i=0;$i < $ns;++$i)
{
$oSymbol = $this->mapa->getSymbolObjectById($i);
$nomes = $oSymbol->name;
$adiciona = ms_newLayerObj($this->mapa, $l);
$nomel = $l->name;
$tematemp= $this->mapa->getlayerbyname($nomel);
$c = $tematemp->getClass(0);
$e = $c->getstyle(0);
$e->set("symbolname",$nomes);
$e->set("size",$tamanho);
$e->set("width",$width);
$ico = $c->createLegendIcon(40,40);
$nimg = $ico->saveWebImage();
$pat = $this->mapa->web->imageurl;
$ins .= "<img src='".$nimg."' style='cursor:pointer;border: 5px solid #FFFFFF' title=".$nomes." onclick='".$onclick."'>";
}
fwrite($f,"<?php \$res = \"".$ins."\";?>");
fclose($f);
//copy ($dir."/simbolos".$tipo.".inc",$dir_tmp."/comum/simbolos".$tipo.".inc");
return $ins;
}
else
{
$res = "";
include_once $dir."/simbolos".$tipo.".inc";
return $res;
}
}
/*
function: pegaParametros
Retorna uma lista com parâmetros sobre cada estilo de uma classe.
parameters:
$classe - Índice da classe.
return:
string com o tipo do layer,id do estilo,outlinecolor,backgroundcolor,color,symbolname,size|
*/
function pegaParametros($classe)
{
if(!$this->layer){return "erro";}
$tipoLayer = $this->layer->type;
$classe = $this->layer->getclass($classe);
$numestilos = $classe->numstyles;
for ($i=0;$i<$numestilos;++$i)
{
$linha = array();
$estilo = $classe->getstyle($i);
$linha[] = $i;
$linha[] = corRGB($estilo->outlinecolor);
$linha[] = corRGB($estilo->backgroundcolor);
$linha[] = corRGB($estilo->color);
$linha[] = $estilo->symbolname;
$linha[] = $estilo->size;
$linha[] = $estilo->opacity;
$linhas[] = $tipoLayer."#".implode("#",$linha);
}
//retorna tipo do layer,id do estilo,outlinecolor,backgroundcolor,color,symbolname,size
return implode("|",$linhas);
}
/*
function: aplicaParametro
Aplica um parâmetro em um estilo de uma classe.
parameters:
$classe - Índice da classe.
$estilo - Índice do estilo que será alterado.
$outlinecolor - Cor do contorno.
$backgroundcolor - Cor do fundo.
$color - Cor da frente.
$symbolname - Nome do símbolo.
$size - Tamanho que será aplicado ao símbolo.
$opacidade - Opacidade
*/
function aplicaParametro($classe,$estilo,$outlinecolor,$backgroundcolor,$color,$symbolname,$size,$opacidade)
{
if(!$this->layer){return "erro";}
$classe = $this->layer->getclass($classe);
$estilo = $classe->getstyle($estilo);
if (isset($outlinecolor))
{
$cor = $estilo->outlinecolor;
$nc = explode(",",$outlinecolor);
$cor->setRGB($nc[0],$nc[1],$nc[2]);
}
if (isset($backgroundcolor))
{
$cor = $estilo->backgroundcolor;
$nc = explode(",",$backgroundcolor);
$cor->setRGB($nc[0],$nc[1],$nc[2]);
}
if (isset($color))
{
$cor = $estilo->color;
$nc = explode(",",$color);
$cor->setRGB($nc[0],$nc[1],$nc[2]);
}
if ((isset($symbolname)) && ($symbolname != ""))
{
if(is_numeric($symbolname))
{$estilo->set("symbol",$symbolname);}
else
{$estilo->set("symbolname",$symbolname);}
}
if ((isset ($size)) && ($size != "-1"))
{$estilo->set("size",$size);}
if(isset($opacidade))
{$estilo->set("opacity",$opacidade);}
if ($this->layer->getmetadata("sld") != "")
{
$sld = $this->layer->getmetadata("sld");
reSLD($this->arquivo,$this->nome,$sld);
}
$this->layer->setMetaData("cache","");
return "ok";
}
/*
function: pegaParametrosLegImg
Pega os parâmetros da legenda embebida no mapa.
return:
array - "imagecolor"=>$imagecolor,"transparent"=>transparent,"position"=>$position,"status"=>$status,"outlinecolor"=>$outlinecolor,"keyspacingy"=>$keyspacingy,"keyspacingx"=>$keyspacingx,"keysizey"=>$keysizey,"keysizex"=>$keysizex,"heigt"=>$height,"width"=>$width
*/
function pegaParametrosLegImg()
{
$legenda = $this->mapa->legend;
$height = $legenda->height;
$width = $legenda->width;
$keysizex = $legenda->keysizex;
$keysizey = $legenda->keysizey;
$keyspacingx = $legenda->keyspacingx;
$keyspacingy = $legenda->keyspacingy;
$outlinecolor = corRGB($legenda->outlinecolor); //Color of outline of box, -1 for no outline
$status = $legenda->status; //MS_ON, MS_OFF, MS_EMBED
$position = $legenda->position;
if ($position < 99){$position = "10".$position;}
$transparent = $legenda->transparent;
$imagecolor = corRGB($legenda->imagecolor);
$label = $legenda->label;
$font = $label->font;
if($font == MS_BITMAP)
{
$l = $label->size;
if ($l == MS_TINY){$t = 5;}
if ($l == MS_SMALL){$t = 7;}
if ($l == MS_MEDIUM){$t = 10;}
if ($l == MS_LARGE){$t = 12;}
if ($l == MS_GIANT){$t = 14;}
$labelsize = $t;
}
else
$labelsize = $label->size;
$tipofonte = $label->type;
return(array("tipofonte"=>$tipofonte,"font"=>$font,"imagecolor"=>$imagecolor,"transparent"=>transparent,"position"=>$position,"status"=>$status,"outlinecolor"=>$outlinecolor,"keyspacingy"=>$keyspacingy,"keyspacingx"=>$keyspacingx,"keysizey"=>$keysizey,"keysizex"=>$keysizex,"height"=>$height,"width"=>$width,"labelsize"=>$labelsize));
}
/*
function: aplicaParametrosLegImg
Aplica os parâmetros da legenda embebida no mapa.
parameters:
$imagecolor
$position
$status
$outlinecolor
$keyspacingy
$keyspacingx
$keysizey
$keysizex
$heigt
$width
*/
function aplicaParametrosLegImg($fonte,$imagecolor,$position,$status,$outlinecolor,$keyspacingy,$keyspacingx,$keysizey,$keysizex,$height,$width,$labelsize)
{
$legenda = $this->mapa->legend;
$legenda->set("height",$height);
$legenda->set("width",$width);
$legenda->set("keysizex",$keysizex);
$legenda->set("keysizey",$keysizey);
$legenda->set("keyspacingx",$keyspacingx);
$legenda->set("keyspacingy",$keyspacingy);
$corres = $legenda->outlinecolor;
$cor = explode(",",$outlinecolor);
$corres->setRGB($cor[0],$cor[1],$cor[2]);
if ($status == 3)
{$legenda->set("status",MS_EMBED);} //MS_ON, MS_OFF, MS_EMBED
else
{$legenda->set("status",MS_OFF);}
$verifica = $legenda->position;
if ($verifica < 100)
{
if($position > 99){$position = 3;}
}
$legenda->set("position",$position);
$corres = $legenda->imagecolor;
$cor = explode(",",$imagecolor);
$corres->setRGB($cor[0],$cor[1],$cor[2]);
$label = $legenda->label;
if ($fonte != "bitmap")
{
$label->set("type",MS_TRUETYPE);
$label->set("font",$fonte);
$label->set("size",$labelsize);
}
else
{
$label->set("type",MS_BITMAP);
$t = MS_TINY;
if ($labelsize > 5 ){$t = MS_TINY;}
if ($labelsize >= 7 ){$t = MS_SMALL;}
if ($labelsize >= 10 ){$t = MS_MEDIUM;}
if ($labelsize >= 12 ){$t = MS_LARGE;}
if ($labelsize >= 14 ){$t = MS_GIANT;}
$label->set("size",$t);
}
return("ok");
}
}
?>