Commit b1712d973b0889e29345947c8aa64848192f3b7a

Authored by Edmar Moretti
1 parent 6d78cf48

Inclusão de projeto gvsig no testamapfile

Showing 1 changed file with 102 additions and 106 deletions   Show diff stats
testamapfile.php
@@ -91,7 +91,7 @@ if ($tipo == "") @@ -91,7 +91,7 @@ if ($tipo == "")
91 $combo = "<br><select onchange='roda()' id=nomemap ><option value=''>Escolha o arquivo para testar</option>"; 91 $combo = "<br><select onchange='roda()' id=nomemap ><option value=''>Escolha o arquivo para testar</option>";
92 foreach ($arqs["arquivos"] as $arq){ 92 foreach ($arqs["arquivos"] as $arq){
93 $temp = explode(".",$arq); 93 $temp = explode(".",$arq);
94 - if($temp[1] == "map"){ 94 + if($temp[1] == "map" || $temp[1] == "gvp"){
95 $combo .= "<option value='".$temp[0]."'>".$temp[0]."</option>"; 95 $combo .= "<option value='".$temp[0]."'>".$temp[0]."</option>";
96 } 96 }
97 } 97 }
@@ -108,13 +108,9 @@ if (isset($map) &amp;&amp; $map != &quot;&quot;) @@ -108,13 +108,9 @@ if (isset($map) &amp;&amp; $map != &quot;&quot;)
108 if (!isset($iniciar)){$iniciar = 0;} 108 if (!isset($iniciar)){$iniciar = 0;}
109 foreach ($arqs["arquivos"] as $arq) 109 foreach ($arqs["arquivos"] as $arq)
110 { 110 {
111 - if (($conta >= $iniciar) && ($conta < $iniciar+10))  
112 - {  
113 - $temp = explode(".",$arq);  
114 - if($temp[1] == "map") 111 + if (($conta >= $iniciar) && ($conta < $iniciar+10)){
  112 + //arquivos php so sao validos se estiverem em i3geo/temas
115 verifica($arq,$solegenda); 113 verifica($arq,$solegenda);
116 - else  
117 - {echo "<br>Arquivo <i>$map</i> n&atilde;o &eacute; v&aacute;lido. <br>";}  
118 } 114 }
119 $conta++; 115 $conta++;
120 } 116 }
@@ -126,28 +122,25 @@ if (isset($map) &amp;&amp; $map != &quot;&quot;) @@ -126,28 +122,25 @@ if (isset($map) &amp;&amp; $map != &quot;&quot;)
126 echo '</div>'; 122 echo '</div>';
127 echo '<script>if(screen.availWidth > 700){document.getElementById("divGeral").style.width = "700px";}</script>'; 123 echo '<script>if(screen.availWidth > 700){document.getElementById("divGeral").style.width = "700px";}</script>';
128 echo '</body></html>'; 124 echo '</body></html>';
129 -function verifica($map,$solegenda)  
130 -{ 125 +function verifica($map,$solegenda){
131 global $tipo,$locaplic,$postgis_mapa,$versao,$base; 126 global $tipo,$locaplic,$postgis_mapa,$versao,$base;
132 $mapUrl = $map; 127 $mapUrl = $map;
133 - if ($tipo == "mini" && file_exists('temas/miniaturas/'.$map.".mini.png"))  
134 - { 128 + if ($tipo == "mini" && file_exists('temas/miniaturas/'.$map.".mini.png")){
135 Header("Content-type: image/png"); 129 Header("Content-type: image/png");
136 ImagePng(ImageCreateFromPNG('temas/miniaturas/'.$map.".mini.png")); 130 ImagePng(ImageCreateFromPNG('temas/miniaturas/'.$map.".mini.png"));
137 exit; 131 exit;
138 } 132 }
139 - if ($tipo == "grande" && file_exists('temas/miniaturas/'.$map.".grande.png"))  
140 - { 133 + if ($tipo == "grande" && file_exists('temas/miniaturas/'.$map.".grande.png")){
141 Header("Content-type: image/png"); 134 Header("Content-type: image/png");
142 ImagePng(ImageCreateFromPNG('temas/miniaturas/'.$map.".grande.png")); 135 ImagePng(ImageCreateFromPNG('temas/miniaturas/'.$map.".grande.png"));
143 exit; 136 exit;
144 } 137 }
145 ms_ResetErrorList(); 138 ms_ResetErrorList();
146 $tema = ""; 139 $tema = "";
147 - if(file_exists($map))  
148 - {$tema = $map;}  
149 - else  
150 - { 140 + if(file_exists($map)){
  141 + $tema = $map;
  142 + }
  143 + else{
151 $map = str_replace("\\","/",$map); 144 $map = str_replace("\\","/",$map);
152 $map = basename($map); 145 $map = basename($map);
153 if (file_exists('temas/'.$map)) 146 if (file_exists('temas/'.$map))
@@ -156,21 +149,26 @@ function verifica($map,$solegenda) @@ -156,21 +149,26 @@ function verifica($map,$solegenda)
156 {$tema = 'temas/'.$map.".map";} 149 {$tema = 'temas/'.$map.".map";}
157 if (file_exists('temas/'.$map.'.php')) 150 if (file_exists('temas/'.$map.'.php'))
158 {$tema = 'temas/'.$map.".php";} 151 {$tema = 'temas/'.$map.".php";}
  152 + if (file_exists('temas/'.$map.'.gvp'))
  153 + {$tema = 'temas/'.$map.".gvp";}
159 } 154 }
160 - if(($tipo == "") || ($tipo == "todos"))  
161 - {echo "<hr><br><br><span style='color:red' ><b>Testando: $tema </span><pre></b>";}  
162 - if(!file_exists($tema))  
163 - {$tema = $locaplic."/".$tema;}  
164 - if(!file_exists($tema))  
165 - {echo "Arquivo ".$map." n&atilde;o encontrado.";exit;}  
166 - if ($tema != "")  
167 - { 155 + if(($tipo == "") || ($tipo == "todos")){
  156 + echo "<hr><br><br><span style='color:red' ><b>Testando: $tema </span><pre></b>";
  157 + }
  158 + if(!file_exists($tema)){
  159 + $tema = $locaplic."/".$tema;
  160 + }
  161 + if(!file_exists($tema)){
  162 + echo "Arquivo ".$map." n&atilde;o encontrado.";
  163 + exit;
  164 + }
  165 + if ($tema != ""){
168 if($base == "" or !isset($base)){ 166 if($base == "" or !isset($base)){
169 $base = ""; 167 $base = "";
170 - if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))  
171 - {$base = $locaplic."/aplicmap/geral1windowsv".$versao.".map";}  
172 - else  
173 - { 168 + if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')){
  169 + $base = $locaplic."/aplicmap/geral1windowsv".$versao.".map";
  170 + }
  171 + else{
174 if($base == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv'.$versao.'.map')){ 172 if($base == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv'.$versao.'.map')){
175 $base = "/var/www/i3geo/aplicmap/geral1debianv".$versao.".map"; 173 $base = "/var/www/i3geo/aplicmap/geral1debianv".$versao.".map";
176 } 174 }
@@ -180,38 +178,35 @@ function verifica($map,$solegenda) @@ -180,38 +178,35 @@ function verifica($map,$solegenda)
180 if($base == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){ 178 if($base == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){
181 $base = "/opt/www/html/i3geo/aplicmap/geral1v".$versao.".map"; 179 $base = "/opt/www/html/i3geo/aplicmap/geral1v".$versao.".map";
182 } 180 }
183 - if($base == "")  
184 - {$base = $locaplic."/aplicmap/geral1v".$versao.".map";} 181 + if($base == ""){
  182 + $base = $locaplic."/aplicmap/geral1v".$versao.".map";
  183 + }
185 } 184 }
186 } 185 }
187 else{ 186 else{
188 - if(!file_exists($base))  
189 - {$base = $locaplic."/aplicmap/".$base;} 187 + if(!file_exists($base)){
  188 + $base = $locaplic."/aplicmap/".$base;
  189 + }
190 } 190 }
191 //echo $base;exit; 191 //echo $base;exit;
192 $mapa = ms_newMapObj($base); 192 $mapa = ms_newMapObj($base);
193 -  
194 error_reporting(0); 193 error_reporting(0);
195 $numlayers = $mapa->numlayers; 194 $numlayers = $mapa->numlayers;
196 - for ($i=0;$i < $numlayers;$i++)  
197 - { 195 + for ($i=0;$i < $numlayers;$i++){
198 $layern = $mapa->getlayer($i); 196 $layern = $mapa->getlayer($i);
199 - if (!empty($postgis_mapa))  
200 - {  
201 - if ($layern->connectiontype == MS_POSTGIS)  
202 - { 197 + if (!empty($postgis_mapa)){
  198 + if ($layern->connectiontype == MS_POSTGIS){
203 $lcon = $layern->connection; 199 $lcon = $layern->connection;
204 - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa))))  
205 - { 200 + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){
206 if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade 201 if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade
207 {$layern->set("connection",$postgis_mapa);} 202 {$layern->set("connection",$postgis_mapa);}
208 - else  
209 - {$layern->set("connection",$postgis_mapa[$lcon]);} 203 + else{
  204 + $layern->set("connection",$postgis_mapa[$lcon]);
  205 + }
210 } 206 }
211 } 207 }
212 } 208 }
213 } 209 }
214 -  
215 if(!stristr($tema, '.php') === FALSE){ 210 if(!stristr($tema, '.php') === FALSE){
216 echo "<br>Arquivo <i>$tema</i> &eacute; um programa PHP. O teste pode n&atilde;o funcionar.<br>"; 211 echo "<br>Arquivo <i>$tema</i> &eacute; um programa PHP. O teste pode n&atilde;o funcionar.<br>";
217 include_once($locaplic."/".$tema); 212 include_once($locaplic."/".$tema);
@@ -222,15 +217,15 @@ function verifica($map,$solegenda) @@ -222,15 +217,15 @@ function verifica($map,$solegenda)
222 $pegarext = str_replace("temas/","",$pegarext); 217 $pegarext = str_replace("temas/","",$pegarext);
223 eval($pegarext."(\$mapa);"); 218 eval($pegarext."(\$mapa);");
224 } 219 }
225 - else{ 220 + if(!stristr($tema, '.map') === FALSE){
226 if(file_exists($mapUrl)){ 221 if(file_exists($mapUrl)){
227 - if(@ms_newMapObj($mapUrl))  
228 - {$nmapa = ms_newMapObj($mapUrl);} 222 + if(@ms_newMapObj($mapUrl)){
  223 + $nmapa = ms_newMapObj($mapUrl);
  224 + }
229 else{ 225 else{
230 echo "Erro no arquivo $mapUrl <br>"; 226 echo "Erro no arquivo $mapUrl <br>";
231 $error = ms_GetErrorObj(); 227 $error = ms_GetErrorObj();
232 - while($error && $error->code != MS_NOERR)  
233 - { 228 + while($error && $error->code != MS_NOERR){
234 printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message); 229 printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message);
235 $error = $error->next(); 230 $error = $error->next();
236 } 231 }
@@ -238,17 +233,14 @@ function verifica($map,$solegenda) @@ -238,17 +233,14 @@ function verifica($map,$solegenda)
238 } 233 }
239 } 234 }
240 else{ 235 else{
241 - if(@ms_newMapObj($locaplic."/".$tema))  
242 - { 236 + if(@ms_newMapObj($locaplic."/".$tema)){
243 $nmapa = ms_newMapObj($locaplic."/".$tema); 237 $nmapa = ms_newMapObj($locaplic."/".$tema);
244 } 238 }
245 - else  
246 - { 239 + else{
247 echo "erro no arquivo $map <br>"; 240 echo "erro no arquivo $map <br>";
248 echo "Obs.: em alguns testes o mapfile pode falhar se o endere&ccedil;o dos arquivos de s&iacute;mbolos estiverem <br>definidos de forma relativa ao inv&eacute;s de absoluta. Nesses casos, ao abrir o i3Geo, <br>o mapfile poder&aacute; funcionar. <br>"; 241 echo "Obs.: em alguns testes o mapfile pode falhar se o endere&ccedil;o dos arquivos de s&iacute;mbolos estiverem <br>definidos de forma relativa ao inv&eacute;s de absoluta. Nesses casos, ao abrir o i3Geo, <br>o mapfile poder&aacute; funcionar. <br>";
249 $error = ms_GetErrorObj(); 242 $error = ms_GetErrorObj();
250 - while($error && $error->code != MS_NOERR)  
251 - { 243 + while($error && $error->code != MS_NOERR){
252 printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message); 244 printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message);
253 $error = $error->next(); 245 $error = $error->next();
254 } 246 }
@@ -257,18 +249,14 @@ function verifica($map,$solegenda) @@ -257,18 +249,14 @@ function verifica($map,$solegenda)
257 } 249 }
258 $numlayers = $nmapa->numlayers; 250 $numlayers = $nmapa->numlayers;
259 $dados = ""; 251 $dados = "";
260 - for ($i=0;$i < $numlayers;$i++)  
261 - { 252 + for ($i=0;$i < $numlayers;$i++){
262 $layern = $mapa->getlayer($i); 253 $layern = $mapa->getlayer($i);
263 $layern->set("status",MS_DEFAULT); 254 $layern->set("status",MS_DEFAULT);
264 - if (!empty($postgis_mapa))  
265 - {  
266 - if ($layern->connectiontype == MS_POSTGIS)  
267 - { 255 + if (!empty($postgis_mapa)){
  256 + if ($layern->connectiontype == MS_POSTGIS){
268 $lcon = $layern->connection; 257 $lcon = $layern->connection;
269 error_reporting(0); 258 error_reporting(0);
270 - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa))))  
271 - { 259 + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){
272 if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade 260 if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade
273 {$layern->set("connection",$postgis_mapa);} 261 {$layern->set("connection",$postgis_mapa);}
274 else 262 else
@@ -282,51 +270,69 @@ function verifica($map,$solegenda) @@ -282,51 +270,69 @@ function verifica($map,$solegenda)
282 $tipotemp = $layern->type; 270 $tipotemp = $layern->type;
283 $tiporep = $layern->getmetadata("tipooriginal"); 271 $tiporep = $layern->getmetadata("tipooriginal");
284 $layern->set("type",MS_LAYER_POLYGON); 272 $layern->set("type",MS_LAYER_POLYGON);
285 - if ($tiporep == "linear")  
286 - {$layern->set("type",MS_LAYER_LINE);}  
287 - if ($tiporep == "pontual")  
288 - {$layern->set("type",MS_LAYER_POINT);} 273 + if ($tiporep == "linear"){
  274 + $layern->set("type",MS_LAYER_LINE);
  275 + }
  276 + if ($tiporep == "pontual"){
  277 + $layern->set("type",MS_LAYER_POINT);
  278 + }
289 $sld = $layern->generateSLD(); 279 $sld = $layern->generateSLD();
290 - if($sld != "")  
291 - $layern->setmetadata("wms_sld_body",str_replace('"',"'",$sld)); 280 + if($sld != ""){
  281 + $layern->setmetadata("wms_sld_body",str_replace('"',"'",$sld));
  282 + }
292 $layern->set("type",$tipotemp); 283 $layern->set("type",$tipotemp);
293 } 284 }
294 ms_newLayerObj($mapa, $layern); 285 ms_newLayerObj($mapa, $layern);
295 - if ($layern->data == "")  
296 - $dados = $layern->connection;  
297 - else  
298 - $dados = $layern->data;  
299 - $pegarext = $teman; 286 + if ($layern->data == ""){
  287 + $dados = $layern->connection;
  288 + }
  289 + else{
  290 + $dados = $layern->data;
  291 + }
  292 + $pegarext = $layern->name;
300 } 293 }
  294 + zoomTema($pegarext,$mapa);
301 } 295 }
302 - zoomTema($pegarext,$mapa);  
303 - if ($tipo == "mini")  
304 - { 296 + if(!stristr($tema, '.gvp') === FALSE){
  297 + if(file_exists($mapUrl)){
  298 + $gvsiggvp = $mapUrl;
  299 + }
  300 + else{
  301 + $gvsiggvp = $locaplic."/".$tema;
  302 + }
  303 + include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php");
  304 + $gm = new gvsig2mapfile($gvsiggvp);
  305 + $gvsigview = $gm->getViewsNames();
  306 + $gvsigview = $gvsigview[0];
  307 + $dataView = $gm->getViewData($gvsigview);
  308 + $numlayers = $mapn->numlayers;
  309 + $next = $dataView["extent"];
  310 + $ext = $mapa->extent;
  311 + $ext->setextent($next[0],$next[1],$next[2],$next[3]);
  312 + $mapa = $gm->addLayers($mapa,$gvsigview,$dataView["layerNames"]);
  313 + }
  314 + if ($tipo == "mini"){
305 $mapa->setsize(50,50); 315 $mapa->setsize(50,50);
306 $sca = $mapa->scalebar; 316 $sca = $mapa->scalebar;
307 $sca->set("status",MS_OFF); 317 $sca->set("status",MS_OFF);
308 } 318 }
309 - if ($tipo == "grande")  
310 - { 319 + if ($tipo == "grande"){
311 $mapa->setsize(300,300); 320 $mapa->setsize(300,300);
312 $sca = $mapa->scalebar; 321 $sca = $mapa->scalebar;
313 $sca->set("status",MS_OFF); 322 $sca->set("status",MS_OFF);
314 } 323 }
315 - if($tipo == "todos")  
316 - { 324 + if($tipo == "todos"){
317 $mapa->setsize(150,150); 325 $mapa->setsize(150,150);
318 $sca = $mapa->scalebar; 326 $sca = $mapa->scalebar;
319 $sca->set("status",MS_OFF); 327 $sca->set("status",MS_OFF);
320 } 328 }
321 $objImagem = @$mapa->draw(); 329 $objImagem = @$mapa->draw();
322 $objImagemLegenda = @$mapa->drawLegend(); 330 $objImagemLegenda = @$mapa->drawLegend();
323 - if (!$objImagem)  
324 - { 331 + if (!$objImagem){
325 echo "Problemas ao gerar o mapa<br>"; 332 echo "Problemas ao gerar o mapa<br>";
326 $error = ""; 333 $error = "";
327 $error = ms_GetErrorObj(); 334 $error = ms_GetErrorObj();
328 - while($error && $error->code != MS_NOERR)  
329 - { 335 + while($error && $error->code != MS_NOERR){
330 echo "<br>Error in %s: %s<br>", $error->routine, $error->message; 336 echo "<br>Error in %s: %s<br>", $error->routine, $error->message;
331 $error = $error->next(); 337 $error = $error->next();
332 } 338 }
@@ -341,38 +347,32 @@ function verifica($map,$solegenda) @@ -341,38 +347,32 @@ function verifica($map,$solegenda)
341 $nomel = ($objImagemLegenda->imagepath).nomeRandomico()."testel.png"; 347 $nomel = ($objImagemLegenda->imagepath).nomeRandomico()."testel.png";
342 $objImagemLegenda->saveImage($nomel); 348 $objImagemLegenda->saveImage($nomel);
343 $nomerl = ($objImagemLegenda->imageurl).basename($nomel); 349 $nomerl = ($objImagemLegenda->imageurl).basename($nomel);
344 - if(($tipo == "") || ($tipo == "todos"))  
345 - { 350 + if(($tipo == "") || ($tipo == "todos")){
346 if($solegenda == "nao") 351 if($solegenda == "nao")
347 {echo "<img src=".$nomer." /><br>";} 352 {echo "<img src=".$nomer." /><br>";}
348 echo "<img src=".$nomerl." />"; 353 echo "<img src=".$nomerl." />";
349 - if($tipo == "todos")  
350 - {  
351 - echo "<br>".$dados."<br>"; 354 + if($tipo == "todos"){
  355 + echo "<br>".$dados."<br>";
352 } 356 }
353 - if($map != "todos")  
354 - { 357 + if($map != "todos"){
355 echo "<br>Erros:<br>"; 358 echo "<br>Erros:<br>";
356 $error = ""; 359 $error = "";
357 $error = ms_GetErrorObj(); 360 $error = ms_GetErrorObj();
358 - while($error && $error->code != MS_NOERR)  
359 - { 361 + while($error && $error->code != MS_NOERR){
360 echo "<br>Error in %s: %s<br>", $error->routine, $error->message; 362 echo "<br>Error in %s: %s<br>", $error->routine, $error->message;
361 $error = $error->next(); 363 $error = $error->next();
362 } 364 }
363 } 365 }
364 366
365 } 367 }
366 - else  
367 - { 368 + else{
368 Header("Content-type: image/png"); 369 Header("Content-type: image/png");
369 ImagePng(ImageCreateFromPNG($nomec)); 370 ImagePng(ImageCreateFromPNG($nomec));
370 } 371 }
371 //$objImagem->free(); 372 //$objImagem->free();
372 } 373 }
373 } 374 }
374 -function zoomTema($nomelayer,&$mapa)  
375 -{ 375 +function zoomTema($nomelayer,&$mapa){
376 $layer = $mapa->getlayerbyname($nomelayer); 376 $layer = $mapa->getlayerbyname($nomelayer);
377 if($layer->data == "" && $layer->connection == "") 377 if($layer->data == "" && $layer->connection == "")
378 {return;} 378 {return;}
@@ -385,23 +385,19 @@ function zoomTema($nomelayer,&amp;$mapa) @@ -385,23 +385,19 @@ function zoomTema($nomelayer,&amp;$mapa)
385 $ct = $layer->connectiontype; 385 $ct = $layer->connectiontype;
386 if(($ret == "") && ($ct != 1)) 386 if(($ret == "") && ($ct != 1))
387 {return;} 387 {return;}
388 - if ($ret == "")  
389 - { 388 + if ($ret == ""){
390 $ret = $layer->getextent(); 389 $ret = $layer->getextent();
391 //reprojeta o retangulo 390 //reprojeta o retangulo
392 - if (($prjTema != "") && ($prjMapa != $prjTema))  
393 - { 391 + if (($prjTema != "") && ($prjMapa != $prjTema)){
394 $projInObj = ms_newprojectionobj($prjTema); 392 $projInObj = ms_newprojectionobj($prjTema);
395 $projOutObj = ms_newprojectionobj($prjMapa); 393 $projOutObj = ms_newprojectionobj($prjMapa);
396 $ret->project($projInObj, $projOutObj); 394 $ret->project($projInObj, $projOutObj);
397 } 395 }
398 $extatual->setextent($ret->minx,$ret->miny,$ret->maxx,$ret->maxy); 396 $extatual->setextent($ret->minx,$ret->miny,$ret->maxx,$ret->maxy);
399 } 397 }
400 - else  
401 - { 398 + else{
402 $ret = explode(" ",$ret); 399 $ret = explode(" ",$ret);
403 $extatual->setextent($ret[0],$ret[1],$ret[2],$ret[3]); 400 $extatual->setextent($ret[0],$ret[1],$ret[2],$ret[3]);
404 } 401 }
405 } 402 }
406 -  
407 ?> 403 ?>