Commit 7b9c91bf1af154e0407ae8ccbf093c8e864f2ddb

Authored by Edmar Moretti
1 parent 3b9a8fef

Contorno de erro do Mapserver na versão 6.0.3 ao criar imagens via save()

admin/admin.db
No preview for this file type
classesphp/mapa_googlemaps.php
1   -<?php
2   -/*
3   -Title: mapa_googlemaps.php
4   -
5   -Faz o processamento de um mapfile segundo as necessidades do i3geo, como por exemplo, fazendo a substitui&ccedil;&atilde;o
6   -das vari&aacute;veis de conex&atilde;o com banco e outras opera&ccedil;&otilde;es espec&iacute;ficas do i3Geo.
7   -
8   -&Eacute; utilizado especificamente nas interfaces que utilizam a biblioteca Googlemaps.
9   -
10   -Precisa do código da "section" PHP aberta pelo i3Geo ou o código para acesso especial indicado no par&acirc;metro telaR
11   -(veja a ferramenta TELAREMOTA).
12   -
13   -Parametros:
14   -
15   -g_sid {string} - código da "section" PHP
16   -
17   -telaR {string} - (opcional) utilizado para autorizar o uso do mapfile aberto (deve estar registrado em $fingerprint (vari&aacute;vel de se&ccedil;&atilde;o)
18   -
19   -tipolayer {fundo|} - (opcional) indica que a imagem a ser produzida comp&otilde;e o fundo do mapa
20   -
21   -BBOX {xmin xmax ymin ymax} - extens&atilde;o geogr&aacute;fica a ser utilizada no desenho do mapa
22   -
23   -WIDTH {numeric} - largura do mapa
24   -
25   -HEIGHT {numeric} - altura do mapa
26   -
27   -layer {string} - código do layer existente no mapa que ser&aacute; desenhado (ignorado quando telaR for definido)
28   -
29   -DESLIGACACHE {sim|nao} - for&ccedil;a a n&atilde;o usar o cache de imagens qd definido como "sim", do contr&aacute;rio, o uso ou n&atilde;o do cache ser&aacute; definido automaticamente
30   -
31   -TIPOIMAGEM {cinza|sepiaclara|sepianormal|negativo|detectaBordas|embassa|gaussian_blur|selective_blur|mean_removal|pixelate
32   -} - filtro de imagem que ser&aacute; aplicado na imagem
33   -
34   -
35   -Licenca:
36   -
37   -GPL2
38   -
39   -i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
40   -
41   -Direitos Autorais Reservados (c) 2006 Minist&eacute;rio do Meio Ambiente Brasil
42   -Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com
43   -
44   -Este programa &eacute; software livre; voc&ecirc; pode redistribu&iacute;-lo
45   -e/ou modific&aacute;-lo sob os termos da Licen&ccedil;a P&uacute;blica Geral
46   -GNU conforme publicada pela Free Software Foundation;
47   -
48   -Este programa &eacute; distribu&iacute;do na expectativa de que seja &uacute;til,
49   -por&eacute;m, SEM NENHUMA GARANTIA; nem mesmo a garantia impl&iacute;cita
50   -de COMERCIABILIDADE OU ADEQUA&Ccedil;&Atilde;O A UMA FINALIDADE ESPEC&Iacute;FICA.
51   -Consulte a Licen&ccedil;a P&uacute;blica Geral do GNU para mais detalhes.
52   -Voc&ecirc; deve ter recebido uma cópia da Licen&ccedil;a P&uacute;blica Geral do
53   -GNU junto com este programa; se n&atilde;o, escreva para a
54   -Free Software Foundation, Inc., no endere&ccedil;o
55   -59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
56   -
57   -Arquivo:
58   -
59   -i3geo/classesphp/mapa_googlemaps.php
60   -
61   -*/
62   -//error_reporting(E_ALL);
63   -error_reporting(0);
64   -clearstatcache();
65   -//verifica&ccedil;&atilde;o de seguran&ccedil;a
66   -$_SESSION = array();
67   -session_name("i3GeoPHP");
68   -if(@$_GET["g_sid"]){
69   - session_id($_GET["g_sid"]);
70   -}
71   -else{
72   - ilegal();
73   -}
74   -session_start();
75   -if(@$_SESSION["fingerprint"]){
76   - $f = explode(",",$_SESSION["fingerprint"]);
77   - if (md5('I3GEOSEC' . $_SERVER['HTTP_USER_AGENT'] . session_id()) != $f[0] && !in_array($_GET["telaR"],$f) ){
78   - ilegal();
79   - } else{
80   - if($img->imagepath == "")
81   - {echo "Erro IMAGEPATH vazio";exit;}
82   - if(ms_GetVersionInt() != 60003 ){
83   - header('Content-Type: image/png');
84   - $img->saveImage();
85   - }
86   - else{
87   - $nomer = ($img->imagepath)."temp".nomeRand().".png";
88   - $img->saveImage($nomer);
89   - $img = imagecreatefrompng($nomer);
90   - imagealphablending($img, false);
91   - imagesavealpha($img, true);
92   - ob_clean();
93   - echo header("Content-type: image/png \n\n");
94   - imagepng($img);
95   - imagedestroy($img);
96   - }
97   - }
98   -}
99   -else{
100   - exit;
101   -}
102   -if(!isset($_SESSION["map_file"])){
103   - exit;
104   -}
105   -//
106   -$map_fileX = $_SESSION["map_file"];
107   -$postgis_mapa = $_SESSION["postgis_mapa"];
108   -$cachedir = $_SESSION["cachedir"];
109   -//
110   -//converte a requisi&ccedil;&atilde;o do tile em coordenadas geo
111   -//http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#tile_numbers_to_lon.2Flat_2
112   -//
113   -$x = $_GET["X"];
114   -$y = $_GET["Y"];
115   -$z = $_GET["Z"];
116   -
  1 +<?php
  2 +/*
  3 +Title: mapa_googlemaps.php
  4 +
  5 +Faz o processamento de um mapfile segundo as necessidades do i3geo, como por exemplo, fazendo a substitui&ccedil;&atilde;o
  6 +das vari&aacute;veis de conex&atilde;o com banco e outras opera&ccedil;&otilde;es espec&iacute;ficas do i3Geo.
  7 +
  8 +&Eacute; utilizado especificamente nas interfaces que utilizam a biblioteca Googlemaps.
  9 +
  10 +Precisa do codigo da "section" PHP aberta pelo i3Geo ou o codigo para acesso especial indicado no par&acirc;metro telaR
  11 +(veja a ferramenta TELAREMOTA).
  12 +
  13 +Parametros:
  14 +
  15 +g_sid {string} - codigo da "section" PHP
  16 +
  17 +telaR {string} - (opcional) utilizado para autorizar o uso do mapfile aberto (deve estar registrado em $fingerprint (vari&aacute;vel de se&ccedil;&atilde;o)
  18 +
  19 +tipolayer {fundo|} - (opcional) indica que a imagem a ser produzida comp&otilde;e o fundo do mapa
  20 +
  21 +BBOX {xmin xmax ymin ymax} - extens&atilde;o geogr&aacute;fica a ser utilizada no desenho do mapa
  22 +
  23 +WIDTH {numeric} - largura do mapa
  24 +
  25 +HEIGHT {numeric} - altura do mapa
  26 +
  27 +layer {string} - codigo do layer existente no mapa que ser&aacute; desenhado (ignorado quando telaR for definido)
  28 +
  29 +DESLIGACACHE {sim|nao} - for&ccedil;a a n&atilde;o usar o cache de imagens qd definido como "sim", do contr&aacute;rio, o uso ou n&atilde;o do cache ser&aacute; definido automaticamente
  30 +
  31 +TIPOIMAGEM {cinza|sepiaclara|sepianormal|negativo|detectaBordas|embassa|gaussian_blur|selective_blur|mean_removal|pixelate
  32 +} - filtro de imagem que ser&aacute; aplicado na imagem
  33 +
  34 +
  35 +Licenca:
  36 +
  37 +GPL2
  38 +
  39 +i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
  40 +
  41 +Direitos Autorais Reservados (c) 2006 Minist&eacute;rio do Meio Ambiente Brasil
  42 +Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com
  43 +
  44 +Este programa &eacute; software livre; voc&ecirc; pode redistribu&iacute;-lo
  45 +e/ou modific&aacute;-lo sob os termos da Licen&ccedil;a P&uacute;blica Geral
  46 +GNU conforme publicada pela Free Software Foundation;
  47 +
  48 +Este programa &eacute; distribu&iacute;do na expectativa de que seja &uacute;til,
  49 +por&eacute;m, SEM NENHUMA GARANTIA; nem mesmo a garantia impl&iacute;cita
  50 +de COMERCIABILIDADE OU ADEQUA&Ccedil;&Atilde;O A UMA FINALIDADE ESPEC&Iacute;FICA.
  51 +Consulte a Licen&ccedil;a P&uacute;blica Geral do GNU para mais detalhes.
  52 +Voc&ecirc; deve ter recebido uma copia da Licen&ccedil;a P&uacute;blica Geral do
  53 +GNU junto com este programa; se n&atilde;o, escreva para a
  54 +Free Software Foundation, Inc., no endere&ccedil;o
  55 +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  56 +
  57 +Arquivo:
  58 +
  59 +i3geo/classesphp/mapa_googlemaps.php
  60 +
  61 +*/
  62 +//error_reporting(E_ALL);
  63 +error_reporting(0);
  64 +clearstatcache();
  65 +//verifica&ccedil;&atilde;o de seguran&ccedil;a
  66 +$_SESSION = array();
  67 +session_name("i3GeoPHP");
  68 +if(@$_GET["g_sid"]){
  69 + session_id($_GET["g_sid"]);
  70 +}
  71 +else{
  72 + ilegal();
  73 +}
  74 +session_start();
  75 +if(@$_SESSION["fingerprint"]){
  76 + $f = explode(",",$_SESSION["fingerprint"]);
  77 + if (md5('I3GEOSEC' . $_SERVER['HTTP_USER_AGENT'] . session_id()) != $f[0] && !in_array($_GET["telaR"],$f) ){
  78 + ilegal();
  79 + }
  80 +}
  81 +else{
  82 + exit;
  83 +}
  84 +if(!isset($_SESSION["map_file"])){
  85 + exit;
  86 +}
  87 +//
  88 +$map_fileX = $_SESSION["map_file"];
  89 +$postgis_mapa = $_SESSION["postgis_mapa"];
  90 +$cachedir = $_SESSION["cachedir"];
  91 +//
  92 +//converte a requisi&ccedil;&atilde;o do tile em coordenadas geo
  93 +//http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#tile_numbers_to_lon.2Flat_2
  94 +//
  95 +$x = $_GET["X"];
  96 +$y = $_GET["Y"];
  97 +$z = $_GET["Z"];
  98 +
117 99 $qyfile = dirname($map_fileX)."/".$_GET["layer"].".php";
118   -$qy = file_exists($qyfile);
119   -
  100 +$qy = file_exists($qyfile);
  101 +
120 102 if($qy == false && $_GET["cache"] == "sim" && $_GET["DESLIGACACHE"] != "sim"){
121 103 carregaCacheImagem($_SESSION["cachedir"],$_SESSION["map_file"],$_GET["tms"]);
122   -}
123   -
124   -$n = pow(2,$z);
125   -$lon1 = $x / $n * 360.0 - 180.0;
126   -$lat2 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n))));
127   -$x++;
128   -$y++;
129   -$lon2 = $x / $n * 360.0 - 180.0;
130   -$lat1 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n))));
  104 +}
  105 +
  106 +$n = pow(2,$z);
  107 +$lon1 = $x / $n * 360.0 - 180.0;
  108 +$lat2 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n))));
  109 +$x++;
  110 +$y++;
  111 +$lon2 = $x / $n * 360.0 - 180.0;
  112 +$lat1 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n))));
131 113 $x--;
132   -$y--;
133   -
134   -$projInObj = ms_newprojectionobj("proj=latlong,a=6378137,b=6378137");
135   -$projOutObj = ms_newprojectionobj("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m");
136   -
137   -$poPoint1 = ms_newpointobj();
138   -$poPoint1->setXY($lon1, $lat1);
139   -$poPoint1->project($projInObj, $projOutObj);
140   -$poPoint2 = ms_newpointobj();
141   -$poPoint2->setXY($lon2, $lat2);
142   -$poPoint2->project($projInObj, $projOutObj);
143   -$_GET["BBOX"] = $poPoint1->x." ".$poPoint1->y." ".$poPoint2->x." ".$poPoint2->y;
144   -$_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]);
145   -
146   -$mapa = ms_newMapObj($map_fileX);
147   -$ret = $mapa->extent;
148   -
149   -$cache = false;
150   -if(!isset($_GET["telaR"])){
151   - //no caso de projecoes remotas, o mapfile nao´e alterado
152   - $numlayers = $mapa->numlayers;
153   - for ($i=0;$i < $numlayers;++$i){
154   - $l = $mapa->getlayer($i);
155   - $layerName = $l->name;
156   - $l->set("status",MS_OFF);
157   - if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != ""){
158   - $l->set("template","none.htm");
159   - $l->set("status",MS_DEFAULT);
  114 +$y--;
  115 +
  116 +$projInObj = ms_newprojectionobj("proj=latlong,a=6378137,b=6378137");
  117 +$projOutObj = ms_newprojectionobj("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m");
  118 +
  119 +$poPoint1 = ms_newpointobj();
  120 +$poPoint1->setXY($lon1, $lat1);
  121 +$poPoint1->project($projInObj, $projOutObj);
  122 +$poPoint2 = ms_newpointobj();
  123 +$poPoint2->setXY($lon2, $lat2);
  124 +$poPoint2->project($projInObj, $projOutObj);
  125 +$_GET["BBOX"] = $poPoint1->x." ".$poPoint1->y." ".$poPoint2->x." ".$poPoint2->y;
  126 +$_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]);
  127 +
  128 +$mapa = ms_newMapObj($map_fileX);
  129 +$ret = $mapa->extent;
  130 +
  131 +$cache = false;
  132 +if(!isset($_GET["telaR"])){
  133 + //no caso de projecoes remotas, o mapfile nao e alterado
  134 + $numlayers = $mapa->numlayers;
  135 + for ($i=0;$i < $numlayers;++$i){
  136 + $l = $mapa->getlayer($i);
  137 + $layerName = $l->name;
  138 + $l->set("status",MS_OFF);
  139 + if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != ""){
  140 + $l->set("template","none.htm");
  141 + $l->set("status",MS_DEFAULT);
160 142 if ($l->getmetadata("classesnome") != ""){
161 143 if(!function_exists("autoClasses")){
162 144 include_once("funcoes_gerais.php");
163 145 }
164 146 autoClasses($l,$mapa);
165   - }
166   - if(!empty($postgis_mapa)){
167   - if($l->connectiontype == MS_POSTGIS){
168   - $lcon = $l->connection;
169   - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){
170   - if(($lcon == " ") || ($lcon == "")){
171   - $l->set("connection",$postgis_mapa);
172   - }
173   - else{
174   - $l->set("connection",$postgis_mapa[$lcon]);
175   - }
176   - }
177   - }
178   - }
179   - if($l->getProjection() == "" ){
180   - $l->setProjection("proj=latlong,a=6378137,b=6378137");
181   - }
182   - }
183   - if($layerName == $_GET["layer"]){
184   - if(strtolower($l->getmetadata("cache")) == "sim"){
185   - $cache = true;
186   - }
187   - }
188   - }
189   -}
190   -else{
191   - $mapa->setProjection("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m");
192   - $numlayers = $mapa->numlayers;
193   - for ($i=0;$i < $numlayers;++$i){
194   - $l = $mapa->getlayer($i);
195   - if($l->getProjection() == "" )
196   - {$l->setProjection("proj=latlong,a=6378137,b=6378137");}
197   - }
198   -}
199   -if($_GET["layer"] == "")
200   -{$cache = true;}
201   -
202   -if(($_GET == false) || ($qy) || (strtolower($_GET["DESLIGACACHE"]) == "sim"))
203   -{$cache = false;}
204   -elseif(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum")
205   -{$cache = false;}
206   -
207   -if($cache == true){
208   - carregaCacheImagem();
209   -}
210   -$mapa->setsize(256,256);
211   -$mapext = explode(" ",$_GET["mapext"]);
212   -$mapa->setExtent($mapext[0],$mapext[1],$mapext[2],$mapext[3]);
213   -
214   -$o = $mapa->outputformat;
215   -$o->set("imagemode",MS_IMAGEMODE_RGBA);
216   -
217   -if(!isset($_GET["telaR"])){
218   - $legenda = $mapa->legend;
219   - $legenda->set("status",MS_OFF);
220   - $escala = $mapa->scalebar;
221   - $escala->set("status",MS_OFF);
222   -}
223   -//
224   -//se o layer nao for do tipo fundo
225   -//
226   -if($_GET["tipolayer"] != "fundo")
227   -{$o->set("transparent",MS_TRUE);}
228   -if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum")
229   -{$o->setOption("QUANTIZE_FORCE","OFF");}
230   -if($qy != true){
231   - $img = $mapa->draw();
232   -}
233   -else{
234   - $handle = fopen ($qyfile, "r");
235   - $conteudo = fread ($handle, filesize ($qyfile));
236   - fclose ($handle);
237   - $shp = unserialize($conteudo);
238   - $l = $mapa->getLayerByname($_GET["layer"]);
239   - $indxlayer = $l->index;
240   - if ($l->connectiontype !== MS_POSTGIS){
241   - foreach ($shp as $indx)
242   - {$mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);}
243   - $qm = $mapa->querymap;
244   - $qm->set("width",255);
245   - $qm->set("height",255);
246   - $img = $mapa->drawQuery();
247   - }
248   - else{
249   - $img = $mapa->draw();
250   - $c = $mapa->querymap->color;
251   - $numclasses = $l->numclasses;
252   - if ($numclasses > 0)
253   - {
254   - $classe0 = $l->getClass(0);
255   - $classe0->setexpression("");
256   - $classe0->set("name"," ");
257   - for ($i=1; $i < $numclasses; ++$i)
258   - {
259   - $classe = $l->getClass($i);
260   - $classe->set("status",MS_DELETE);
261   - }
262   - }
263   - $cor = $classe0->getstyle(0)->color;
264   - $cor->setrgb($c->red,$c->green,$c->blue);
265   - $cor = $classe0->getstyle(0)->outlinecolor;
266   - $cor->setrgb($c->red,$c->green,$c->blue);
267   - $v = versaoMS();
268   - if($v["principal"] == 6){
269   - $l->open();
270   - foreach ($shp as $indx){
271   - $shape = $l->getShape(new resultObj($indx));
272   - $shape->draw($mapa,$l,$img);
273   - }
274   - $l->close();
275   - }
276   - else{
277   - $l->open();
278   - foreach ($shp as $indx){
279   - $shape = $l->getfeature($indx,-1);
280   - $shape->draw($mapa,$l,$img);
281   - }
282   - $l->close();
283   - }
284   - }
285   -}
286   -if (!function_exists('imagepng')){
287   - $s = PHP_SHLIB_SUFFIX;
288   - @dl( 'php_gd.'.$s );
289   - if (!function_exists('imagepng'))
290   - {@dl( 'php_gd2.'.$s );}
291   - if (!function_exists('imagepng'))
292   - {$_GET["TIPOIMAGEM"] = "";}
293   -}
294   -if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum"){
295   - if($img->imagepath == "")
296   - {echo "Erro IMAGEPATH vazio";exit;}
297   - $nomer = ($img->imagepath)."filtroimgtemp".nomeRand().".png";
298   - $img->saveImage($nomer);
299   - filtraImg($nomer,trim($_GET["TIPOIMAGEM"]));
300   - $img = imagecreatefrompng($nomer);
301   - imagealphablending($img, false);
302   - imagesavealpha($img, true);
303   - ob_clean();
304   - echo header("Content-type: image/png \n\n");
305   - imagepng($img);
306   -}
307   -else{
  147 + }
  148 + if(!empty($postgis_mapa)){
  149 + if($l->connectiontype == MS_POSTGIS){
  150 + $lcon = $l->connection;
  151 + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){
  152 + if(($lcon == " ") || ($lcon == "")){
  153 + $l->set("connection",$postgis_mapa);
  154 + }
  155 + else{
  156 + $l->set("connection",$postgis_mapa[$lcon]);
  157 + }
  158 + }
  159 + }
  160 + }
  161 + if($l->getProjection() == "" ){
  162 + $l->setProjection("proj=latlong,a=6378137,b=6378137");
  163 + }
  164 + }
  165 + if($layerName == $_GET["layer"]){
  166 + if(strtolower($l->getmetadata("cache")) == "sim"){
  167 + $cache = true;
  168 + }
  169 + }
  170 + }
  171 +}
  172 +else{
  173 + $mapa->setProjection("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m");
  174 + $numlayers = $mapa->numlayers;
  175 + for ($i=0;$i < $numlayers;++$i){
  176 + $l = $mapa->getlayer($i);
  177 + if($l->getProjection() == "" )
  178 + {$l->setProjection("proj=latlong,a=6378137,b=6378137");}
  179 + }
  180 +}
  181 +if($_GET["layer"] == "")
  182 +{$cache = true;}
  183 +
  184 +if(($_GET == false) || ($qy) || (strtolower($_GET["DESLIGACACHE"]) == "sim"))
  185 +{$cache = false;}
  186 +elseif(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum")
  187 +{$cache = false;}
  188 +
  189 +if($cache == true){
  190 + carregaCacheImagem();
  191 +}
  192 +$mapa->setsize(256,256);
  193 +$mapext = explode(" ",$_GET["mapext"]);
  194 +$mapa->setExtent($mapext[0],$mapext[1],$mapext[2],$mapext[3]);
  195 +
  196 +$o = $mapa->outputformat;
  197 +$o->set("imagemode",MS_IMAGEMODE_RGBA);
  198 +
  199 +if(!isset($_GET["telaR"])){
  200 + $legenda = $mapa->legend;
  201 + $legenda->set("status",MS_OFF);
  202 + $escala = $mapa->scalebar;
  203 + $escala->set("status",MS_OFF);
  204 +}
  205 +//
  206 +//se o layer nao for do tipo fundo
  207 +//
  208 +if($_GET["tipolayer"] != "fundo")
  209 +{$o->set("transparent",MS_TRUE);}
  210 +if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum")
  211 +{$o->setOption("QUANTIZE_FORCE","OFF");}
  212 +if($qy != true){
  213 + $img = $mapa->draw();
  214 +}
  215 +else{
  216 + $handle = fopen ($qyfile, "r");
  217 + $conteudo = fread ($handle, filesize ($qyfile));
  218 + fclose ($handle);
  219 + $shp = unserialize($conteudo);
  220 + $l = $mapa->getLayerByname($_GET["layer"]);
  221 + $indxlayer = $l->index;
  222 + if ($l->connectiontype !== MS_POSTGIS){
  223 + foreach ($shp as $indx)
  224 + {$mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);}
  225 + $qm = $mapa->querymap;
  226 + $qm->set("width",255);
  227 + $qm->set("height",255);
  228 + $img = $mapa->drawQuery();
  229 + }
  230 + else{
  231 + $img = $mapa->draw();
  232 + $c = $mapa->querymap->color;
  233 + $numclasses = $l->numclasses;
  234 + if ($numclasses > 0)
  235 + {
  236 + $classe0 = $l->getClass(0);
  237 + $classe0->setexpression("");
  238 + $classe0->set("name"," ");
  239 + for ($i=1; $i < $numclasses; ++$i)
  240 + {
  241 + $classe = $l->getClass($i);
  242 + $classe->set("status",MS_DELETE);
  243 + }
  244 + }
  245 + $cor = $classe0->getstyle(0)->color;
  246 + $cor->setrgb($c->red,$c->green,$c->blue);
  247 + $cor = $classe0->getstyle(0)->outlinecolor;
  248 + $cor->setrgb($c->red,$c->green,$c->blue);
  249 + $v = versaoMS();
  250 + if($v["principal"] == 6){
  251 + $l->open();
  252 + foreach ($shp as $indx){
  253 + $shape = $l->getShape(new resultObj($indx));
  254 + $shape->draw($mapa,$l,$img);
  255 + }
  256 + $l->close();
  257 + }
  258 + else{
  259 + $l->open();
  260 + foreach ($shp as $indx){
  261 + $shape = $l->getfeature($indx,-1);
  262 + $shape->draw($mapa,$l,$img);
  263 + }
  264 + $l->close();
  265 + }
  266 + }
  267 +}
  268 +if (!function_exists('imagepng')){
  269 + $s = PHP_SHLIB_SUFFIX;
  270 + @dl( 'php_gd.'.$s );
  271 + if (!function_exists('imagepng'))
  272 + {@dl( 'php_gd2.'.$s );}
  273 + if (!function_exists('imagepng'))
  274 + {$_GET["TIPOIMAGEM"] = "";}
  275 +}
  276 +if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum"){
  277 + if($img->imagepath == "")
  278 + {echo "Erro IMAGEPATH vazio";exit;}
  279 + $nomer = ($img->imagepath)."filtroimgtemp".nomeRand().".png";
  280 + $img->saveImage($nomer);
  281 + filtraImg($nomer,trim($_GET["TIPOIMAGEM"]));
  282 + $img = imagecreatefrompng($nomer);
  283 + imagealphablending($img, false);
  284 + imagesavealpha($img, true);
  285 + ob_clean();
  286 + echo header("Content-type: image/png \n\n");
  287 + imagepng($img);
  288 +}
  289 +else{
308 290 if($cache == true){
309 291 $nomer = salvaCacheImagem();
310 292 header('Content-Length: '.filesize($nomer));
... ... @@ -315,9 +297,7 @@ else{
315 297 fpassthru(fopen($nomer, 'rb'));
316 298 }
317 299 else{
318   - if($img->imagepath == "")
319   - {echo "Erro IMAGEPATH vazio";exit;}
320   - if(ms_GetVersionInt() != 60003 ){
  300 + if(ms_GetVersionInt() != 60003 ){
321 301 header('Content-Type: image/png');
322 302 $img->saveImage();
323 303 }
... ... @@ -333,30 +313,30 @@ else{
333 313 imagedestroy($img);
334 314 }
335 315 }
336   - exit;
337   -}
338   -//$cachedir e definido no ms_configura.php
  316 + exit;
  317 +}
  318 +//$cachedir e definido no ms_configura.php
339 319 function salvaCacheImagem(){
340   - global $img,$cachedir,$x,$y,$z,$map_fileX;
  320 + global $img,$cachedir,$x,$y,$z,$map_fileX;
341 321 $layer = $_GET["layer"];
342 322 if($layer == "")
343 323 {$layer = "fundo";}
344   - if($cachedir == ""){
345   - $cachedir = dirname(dirname($map_fileX))."/cache";
  324 + if($cachedir == ""){
  325 + $cachedir = dirname(dirname($map_fileX))."/cache";
346 326 }
347   - $c = $cachedir."/googlemaps/$layer/$z/$x";
348   - if(!file_exists($c."/$y.png")){
349   - mkdir($cachedir."/googlemaps/$layer/$z/$x",0777,true);
350   - $img->saveImage($c."/$y.png");
351   - chmod($c."/$y.png",0777);
  327 + $c = $cachedir."/googlemaps/$layer/$z/$x";
  328 + if(!file_exists($c."/$y.png")){
  329 + mkdir($cachedir."/googlemaps/$layer/$z/$x",0777,true);
  330 + $img->saveImage($c."/$y.png");
  331 + chmod($c."/$y.png",0777);
352 332 }
353 333 return $nome;
354   -}
  334 +}
355 335 function carregaCacheImagem(){
356   - global $img,$cachedir,$x,$y,$z,$map_fileX;
357   - $layer = $_GET["layer"];
  336 + global $img,$cachedir,$x,$y,$z,$map_fileX;
  337 + $layer = $_GET["layer"];
358 338 if($layer == "")
359   - {$layer = "fundo";}
  339 + {$layer = "fundo";}
360 340 if($cachedir == ""){
361 341 $cachedir = dirname(dirname($map_fileX))."/cache";
362 342 }
... ... @@ -367,104 +347,104 @@ function carregaCacheImagem(){
367 347 fpassthru(fopen($c."/$y.png", 'rb'));
368 348 exit;
369 349 }
370   -}
371   -/*
372   -function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){
373   - global $img,$map_size;
374   - //layers que s&atilde;o sempre iguais
375   - //error_reporting(E_ALL);
376   - if($layer == "copyright" || $layer == "")
377   - {$bbox = "";}
378   - if($layer == "")
379   - {$layer = "fundo";}
380   - if($cachedir == "")
381   - {$cachedir = dirname(dirname($map))."/cache/googlemaps/".$layer;}
382   - else
383   - {$cachedir = $cachedir."/googlemaps/".$layer;}
384   - @mkdir($cachedir,0777);
385   - $nome = $cachedir."/".$w.$h.$bbox.".png";
386   - if(!file_exists($nome))
387   - {$img->saveImage($nome);}
388   - return $nome;
389   -}
390   -function carregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){
391   - if($layer == "copyright" || $layer == "")
392   - {$bbox = "";}
393   - if($layer == "")
394   - {$layer = "fundo";}
395   - $nome = $w.$h.$bbox.".png";
396   - if($cachedir == "")
397   - {$nome = dirname(dirname($map))."/cache/googlemaps/".$layer."/".$nome;}
398   - else
399   - {$nome = $cachedir."/googlemaps/".$layer."/".$nome;}
400   - if(file_exists($nome)){
401   - header('Content-Length: '.filesize($nome));
402   - header('Content-Type: image/png');
403   - fpassthru(fopen($nome, 'rb'));
404   - exit;
405   - }
406   -}
407   -*/
408   -function nomeRand($n=10)
409   -{
410   - $nomes = "";
411   - $a = 'azertyuiopqsdfghjklmwxcvbnABCDEFGHIJKLMNOPQRSTUVWXYZ';
412   - $max = 51;
413   - for($i=0; $i < $n; ++$i)
414   - {$nomes .= $a{mt_rand(0, $max)};}
415   - return $nomes;
416   -}
417   -function filtraImg($nomer,$tipoimagem){
418   - include_once("classe_imagem.php");
419   - $tiposImagem = explode(" ",$tipoimagem);
420   - foreach ($tiposImagem as $tipoimagem){
421   - $m = new Imagem($nomer);
422   - if ($tipoimagem == "cinza")
423   - {imagepng($m->cinzaNormal(),str_replace("\\","/",$nomer));}
424   - if ($tipoimagem == "sepiaclara")
425   - {imagepng($m->sepiaClara(),str_replace("\\","/",$nomer));}
426   - if ($tipoimagem == "sepianormal")
427   - {imagepng($m->sepiaNormal(),str_replace("\\","/",$nomer));}
428   - if ($tipoimagem == "negativo")
429   - {imagepng($m->negativo(),str_replace("\\","/",$nomer));}
430   - if ($tipoimagem == "detectaBordas")
431   - {imagepng($m->detectaBordas(),str_replace("\\","/",$nomer));}
432   - if ($tipoimagem == "embassa")
433   - {imagepng($m->embassa(),str_replace("\\","/",$nomer));}
434   - if ($tipoimagem == "gaussian_blur")
435   - {imagepng($m->gaussian_blur(),str_replace("\\","/",$nomer));}
436   - if ($tipoimagem == "selective_blur")
437   - {imagepng($m->selective_blur(),str_replace("\\","/",$nomer));}
438   - if ($tipoimagem == "mean_removal")
439   - {imagepng($m->mean_removal(),str_replace("\\","/",$nomer));}
440   - if ($tipoimagem == "pixelate")
441   - {imagepng($m->pixelate(),str_replace("\\","/",$nomer));}
442   - }
443   -}
444   -function ilegal(){
445   - $img = imagecreatefrompng("../imagens/ilegal.png");
446   - imagealphablending($img, false);
447   - imagesavealpha($img, true);
448   - ob_clean();
449   - echo header("Content-type: image/png \n\n");
450   - imagepng($img);
451   - exit;
452   -}
453   -function versaoMS()
454   -{
455   - $v = "5.0.0";
456   - $vs = explode(" ",ms_GetVersion());
457   - $cvs = count($vs);
458   - for ($i=0;$i<$cvs;++$i)
459   - {
460   - if(trim(strtolower($vs[$i])) == "version")
461   - {
462   - $v = $vs[$i+1];
463   - }
464   - }
465   - $versao["completa"] = $v;
466   - $v = explode(".",$v);
467   - $versao["principal"] = $v[0];
468   - return $versao;
469   -}
  350 +}
  351 +/*
  352 +function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){
  353 + global $img,$map_size;
  354 + //layers que s&atilde;o sempre iguais
  355 + //error_reporting(E_ALL);
  356 + if($layer == "copyright" || $layer == "")
  357 + {$bbox = "";}
  358 + if($layer == "")
  359 + {$layer = "fundo";}
  360 + if($cachedir == "")
  361 + {$cachedir = dirname(dirname($map))."/cache/googlemaps/".$layer;}
  362 + else
  363 + {$cachedir = $cachedir."/googlemaps/".$layer;}
  364 + @mkdir($cachedir,0777);
  365 + $nome = $cachedir."/".$w.$h.$bbox.".png";
  366 + if(!file_exists($nome))
  367 + {$img->saveImage($nome);}
  368 + return $nome;
  369 +}
  370 +function carregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){
  371 + if($layer == "copyright" || $layer == "")
  372 + {$bbox = "";}
  373 + if($layer == "")
  374 + {$layer = "fundo";}
  375 + $nome = $w.$h.$bbox.".png";
  376 + if($cachedir == "")
  377 + {$nome = dirname(dirname($map))."/cache/googlemaps/".$layer."/".$nome;}
  378 + else
  379 + {$nome = $cachedir."/googlemaps/".$layer."/".$nome;}
  380 + if(file_exists($nome)){
  381 + header('Content-Length: '.filesize($nome));
  382 + header('Content-Type: image/png');
  383 + fpassthru(fopen($nome, 'rb'));
  384 + exit;
  385 + }
  386 +}
  387 +*/
  388 +function nomeRand($n=10)
  389 +{
  390 + $nomes = "";
  391 + $a = 'azertyuiopqsdfghjklmwxcvbnABCDEFGHIJKLMNOPQRSTUVWXYZ';
  392 + $max = 51;
  393 + for($i=0; $i < $n; ++$i)
  394 + {$nomes .= $a{mt_rand(0, $max)};}
  395 + return $nomes;
  396 +}
  397 +function filtraImg($nomer,$tipoimagem){
  398 + include_once("classe_imagem.php");
  399 + $tiposImagem = explode(" ",$tipoimagem);
  400 + foreach ($tiposImagem as $tipoimagem){
  401 + $m = new Imagem($nomer);
  402 + if ($tipoimagem == "cinza")
  403 + {imagepng($m->cinzaNormal(),str_replace("\\","/",$nomer));}
  404 + if ($tipoimagem == "sepiaclara")
  405 + {imagepng($m->sepiaClara(),str_replace("\\","/",$nomer));}
  406 + if ($tipoimagem == "sepianormal")
  407 + {imagepng($m->sepiaNormal(),str_replace("\\","/",$nomer));}
  408 + if ($tipoimagem == "negativo")
  409 + {imagepng($m->negativo(),str_replace("\\","/",$nomer));}
  410 + if ($tipoimagem == "detectaBordas")
  411 + {imagepng($m->detectaBordas(),str_replace("\\","/",$nomer));}
  412 + if ($tipoimagem == "embassa")
  413 + {imagepng($m->embassa(),str_replace("\\","/",$nomer));}
  414 + if ($tipoimagem == "gaussian_blur")
  415 + {imagepng($m->gaussian_blur(),str_replace("\\","/",$nomer));}
  416 + if ($tipoimagem == "selective_blur")
  417 + {imagepng($m->selective_blur(),str_replace("\\","/",$nomer));}
  418 + if ($tipoimagem == "mean_removal")
  419 + {imagepng($m->mean_removal(),str_replace("\\","/",$nomer));}
  420 + if ($tipoimagem == "pixelate")
  421 + {imagepng($m->pixelate(),str_replace("\\","/",$nomer));}
  422 + }
  423 +}
  424 +function ilegal(){
  425 + $img = imagecreatefrompng("../imagens/ilegal.png");
  426 + imagealphablending($img, false);
  427 + imagesavealpha($img, true);
  428 + ob_clean();
  429 + echo header("Content-type: image/png \n\n");
  430 + imagepng($img);
  431 + exit;
  432 +}
  433 +function versaoMS()
  434 +{
  435 + $v = "5.0.0";
  436 + $vs = explode(" ",ms_GetVersion());
  437 + $cvs = count($vs);
  438 + for ($i=0;$i<$cvs;++$i)
  439 + {
  440 + if(trim(strtolower($vs[$i])) == "version")
  441 + {
  442 + $v = $vs[$i+1];
  443 + }
  444 + }
  445 + $versao["completa"] = $v;
  446 + $v = explode(".",$v);
  447 + $versao["principal"] = $v[0];
  448 + return $versao;
  449 +}
470 450 ?>
471 451 \ No newline at end of file
... ...
classesphp/mapa_openlayers.php
... ... @@ -7,7 +7,7 @@ das vari&amp;aacute;veis de conex&amp;atilde;o com banco e outras opera&amp;ccedil;&amp;otilde;e
7 7  
8 8 &Eacute; utilizado especificamente nas interfaces que utilizam a biblioteca OpenLayers em LAYERS do tipo WMS.
9 9  
10   -Precisa do código da "section" PHP aberta pelo i3Geo ou o código para acesso especial indicado no par&acirc;metro telaR
  10 +Precisa do codigo da "section" PHP aberta pelo i3Geo ou o codigo para acesso especial indicado no par&acirc;metro telaR
11 11 (veja a ferramenta TELAREMOTA).
12 12  
13 13 Parametros:
... ... @@ -24,7 +24,7 @@ WIDTH {numeric} - largura do mapa
24 24  
25 25 HEIGHT {numeric} - altura do mapa
26 26  
27   -layer {string} - código do layer existente no mapa que ser&aacute; desenhado (ignorado quando telaR for definido)
  27 +layer {string} - codigo do layer existente no mapa que ser&aacute; desenhado (ignorado quando telaR for definido)
28 28  
29 29 DESLIGACACHE {sim|nao} - for&ccedil;a a n&atilde;o usar o cache de imagens qd definido como "sim", do contr&aacute;rio, o uso ou n&atilde;o do cache ser&aacute; definido automaticamente
30 30  
... ...