Commit 4ea8405390c9cccffe9a4faac7fcb1c751baf421

Authored by Edmar Moretti
1 parent cd128f5e

Adaptações dos códigos para a versão 6 do Mapserver

classesphp/classe_analise.php
... ... @@ -74,6 +74,12 @@ class Analise
74 74 */
75 75 public $qyfile;
76 76 /*
  77 + Variavel: $v
  78 +
  79 + Versão atual do Mapserver (primeiro dígito)
  80 + */
  81 + public $v;
  82 + /*
77 83 Variavel: $dbaseExiste
78 84  
79 85 Indica se a biblioteca dbase está carregada
... ... @@ -100,6 +106,8 @@ $ext - Extensão geográfica do mapa
100 106 include_once($locaplic."/funcoes_gerais.php");
101 107 else
102 108 include_once("funcoes_gerais.php");
  109 + $this->v = versao();
  110 + $this->v = $this->v["principal"];
103 111 $this->dbaseExiste = false;
104 112 if(function_exists("dbase_create"))
105 113 {$this->dbaseExiste = true;}
... ... @@ -1026,9 +1034,13 @@ $locaplic - Localização do I3geo.
1026 1034 $spts = array();
1027 1035 for ($i = 0; $i < $res_count; ++$i)
1028 1036 {
1029   - $result = $layerPt->getResult($i);
1030   - $shp_index = $result->shapeindex;
1031   - $shape = $layerPt->getfeature($shp_index,-1);
  1037 + if($this->v == 6)
  1038 + {$shape = $layerPt->getShape($layerPt->getResult($i));}
  1039 + else{
  1040 + $result = $layerPt->getResult($i);
  1041 + $shp_index = $result->shapeindex;
  1042 + $shape = $layerPt->getfeature($shp_index,-1);
  1043 + }
1032 1044 $spts[] = $shape;
1033 1045 }
1034 1046 $layerPt->close();
... ... @@ -1098,10 +1110,13 @@ $locaplic - Localização do I3geo.
1098 1110 if($sopen == MS_FAILURE){return "erro";}
1099 1111 if ($res_count > 0 && $layer->getResult(0) !== FALSE)
1100 1112 {
1101   - $result = $layer->getResult(0);
1102   - $shp_index = $result->shapeindex;
1103   -
1104   - $shape = $layer->getfeature($shp_index,-1);
  1113 + if($this->v == 6)
  1114 + {$shape = $layer->getShape($layer->getResult(0));}
  1115 + else{
  1116 + $result = $layer->getResult(0);
  1117 + $shp_index = $result->shapeindex;
  1118 + $shape = $layer->getfeature($shp_index,-1);
  1119 + }
1105 1120 foreach ($itens as $item)
1106 1121 {$reg[] = $this->truncaS($shape->values[$item]);}
1107 1122 }
... ... @@ -1190,9 +1205,13 @@ function distanciaptpt($temaorigem,$temadestino,$temaoverlay,$locaplic,$itemorig
1190 1205 $res_count = $layerorigem->getNumresults();
1191 1206 for ($i = 0; $i < $res_count; ++$i)
1192 1207 {
1193   - $result = $layerorigem->getResult($i);
1194   - $shp_index = $result->shapeindex;
1195   - $shapesorigem[] = $layerorigem->getshape(-1, $shp_index);
  1208 + if($this->v == 6)
  1209 + {$shapesorigem[] = $layerorigem->getShape($layerorigem->getResult($i));}
  1210 + else{
  1211 + $result = $layerorigem->getResult($i);
  1212 + $shp_index = $result->shapeindex;
  1213 + $shapesorigem[] = $layerorigem->getshape(-1, $shp_index);
  1214 + }
1196 1215 }
1197 1216 $layerorigem->close();
1198 1217 $layeroverlay->set("tolerance",0);
... ... @@ -1212,9 +1231,13 @@ function distanciaptpt($temaorigem,$temadestino,$temaoverlay,$locaplic,$itemorig
1212 1231  
1213 1232 for ($i = 0; $i < $res_count; ++$i)
1214 1233 {
1215   - $result = $layerdestino->getResult($i);
1216   - $shp_index = $result->shapeindex;
1217   - $shapesdestino[] = $layerdestino->getshape(-1, $shp_index);
  1234 + if($this->v == 6)
  1235 + {$shapesdestino[] = $layerdestino->getShape($layerdestino->getResult($i));}
  1236 + else{
  1237 + $result = $layerdestino->getResult($i);
  1238 + $shp_index = $result->shapeindex;
  1239 + $shapesdestino[] = $layerdestino->getshape(-1, $shp_index);
  1240 + }
1218 1241 }
1219 1242 $layerdestino->close();
1220 1243 $rect = $this->mapa->extent;
... ... @@ -1332,9 +1355,13 @@ nome do layer criado com o buffer.
1332 1355 //pega um shape especifico
1333 1356 for ($i = 0; $i < $res_count; ++$i)
1334 1357 {
1335   - $result = $this->layer->getResult($i);
1336   - $shp_index = $result->shapeindex;
1337   - $listaShapes[] = $this->layer->getfeature($shp_index,-1);
  1358 + if($this->v == 6)
  1359 + {$listaShapes[] = $this->layer->getShape($this->layer->getResult($i));}
  1360 + else{
  1361 + $result = $this->layer->getResult($i);
  1362 + $shp_index = $result->shapeindex;
  1363 + $listaShapes[] = $this->layer->getfeature($shp_index,-1);
  1364 + }
1338 1365 }
1339 1366 $fechou = $this->layer->close();
1340 1367 }
... ... @@ -1369,7 +1396,7 @@ nome do layer criado com o buffer.
1369 1396 {
1370 1397 $ns = $buffers[0];
1371 1398 for($s=1;$s < count($buffers);$s++)
1372   - {$ns = $ns->union_geos($buffers[$s]);}
  1399 + {$ns = $ns->union($buffers[$s]);}
1373 1400 $buffers = array($ns);
1374 1401 $shapes = array($shapes[0]);
1375 1402 }
... ... @@ -1460,9 +1487,13 @@ $item {string} - (opcional) Item q será utilizado para ponderar os valores.
1460 1487 $ys = 0;
1461 1488 for ($i = 0; $i < $res_count; ++$i)
1462 1489 {
1463   - $result = $this->layer->getResult($i);
1464   - $shp_index = $result->shapeindex;
1465   - $shape = $this->layer->getfeature($shp_index,-1);
  1490 + if($this->v == 6)
  1491 + {$shape = $this->layer->getShape($this->layer->getResult($i));}
  1492 + else{
  1493 + $result = $this->layer->getResult($i);
  1494 + $shp_index = $result->shapeindex;
  1495 + $shape = $this->layer->getfeature($shp_index,-1);
  1496 + }
1466 1497 if($item != "")
1467 1498 {$pondera = $shape->values[$item];}
1468 1499 $pt = $shape->line(0)->point(0);
... ... @@ -1551,9 +1582,13 @@ $locaplic - Localização do I3geo.
1551 1582 //pega um shape especifico
1552 1583 for ($i = 0; $i < $res_count; ++$i)
1553 1584 {
1554   - $result = $this->layer->getResult($i);
1555   - $shp_index = $result->shapeindex;
1556   - $shape = $this->layer->getfeature($shp_index,-1);
  1585 + if($this->v == 6)
  1586 + {$shape = $this->layer->getShape($this->layer->getResult($i));}
  1587 + else{
  1588 + $result = $this->layer->getResult($i);
  1589 + $shp_index = $result->shapeindex;
  1590 + $shape = $this->layer->getfeature($shp_index,-1);
  1591 + }
1557 1592 $LineObj = ms_newLineObj();
1558 1593 $LineObj->add($shape->getCentroid());
1559 1594 $ShapeObj = ms_newShapeObj(MS_SHAPE_POINT);
... ... @@ -2121,9 +2156,13 @@ $locaplic - Localização do I3geo
2121 2156 $res_count = $layerPo->getNumresults();
2122 2157 for ($i = 0; $i < $res_count; ++$i)
2123 2158 {
2124   - $result = $layerPo->getResult($i);
2125   - $shp_index = $result->shapeindex;
2126   - $shape = $layerPo->getfeature($shp_index,-1);
  2159 + if($this->v == 6)
  2160 + {$shape = $layerPo->getShape($layerPo->getResult($i));}
  2161 + else{
  2162 + $result = $layerPo->getResult($i);
  2163 + $shp_index = $result->shapeindex;
  2164 + $shape = $layerPo->getfeature($shp_index,-1);
  2165 + }
2127 2166 $novoreg = array();
2128 2167 foreach($itenspo as $ipo)
2129 2168 {$novoreg[] = $shape->values[$ipo];}
... ... @@ -2182,9 +2221,15 @@ Salva o mapa acrescentando um novo layer com o resultado.
2182 2221 $indices = array();
2183 2222 for ($i = 0; $i < $res_count; ++$i)
2184 2223 {
2185   - $result = $this->layer->getResult($i);
2186   - $shp_index = $result->shapeindex;
2187   - $shape = $this->layer->getfeature($shp_index,-1);
  2224 + if($this->v == 6){
  2225 + $shape = $this->layer->getShape($this->layer->getResult($i));
  2226 + $shp_index = $shape->index;
  2227 + }
  2228 + else{
  2229 + $result = $this->layer->getResult($i);
  2230 + $shp_index = $result->shapeindex;
  2231 + $shape = $this->layer->getfeature($shp_index,-1);
  2232 + }
2188 2233 if($item != "")
2189 2234 $valor = $shape->values[$item];
2190 2235 else
... ... @@ -2202,7 +2247,10 @@ Salva o mapa acrescentando um novo layer com o resultado.
2202 2247 {
2203 2248 foreach ($i as $indice)
2204 2249 {
2205   - $shape = $this->layer->getfeature($indice,-1);
  2250 + if($this->v == 6)
  2251 + {$shape = $this->layer->getShape($this->layer->getResult($indice));}
  2252 + else
  2253 + {$shape = $this->layer->getfeature($indice,-1);}
2206 2254 if($item != "")
2207 2255 $valor = $shape->values[$item];
2208 2256 else
... ... @@ -2224,7 +2272,7 @@ Salva o mapa acrescentando um novo layer com o resultado.
2224 2272 }
2225 2273 else
2226 2274 {
2227   - $dissolve[$valor] = $shape->union_geos($dissolve[$valor]);
  2275 + $dissolve[$valor] = $shape->union($dissolve[$valor]);
2228 2276 }
2229 2277 }
2230 2278 }
... ... @@ -2312,19 +2360,23 @@ $locaplic - Localização do I3geo
2312 2360 $indices = array();
2313 2361 for ($i = 0; $i < $res_count; ++$i)
2314 2362 {
2315   - $result = $this->layer->getResult($i);
2316   - $shp_index = $result->shapeindex;
2317   - $shape = $this->layer->getfeature($shp_index,-1);
  2363 + if($this->v == 6)
  2364 + {$shape = $this->layer->getShape($this->layer->getResult($i));}
  2365 + else{
  2366 + $result = $this->layer->getResult($i);
  2367 + $shp_index = $result->shapeindex;
  2368 + $shape = $this->layer->getfeature($shp_index,-1);
  2369 + }
2318 2370 if($item != "")
2319 2371 $valor = $shape->values[$item];
2320 2372 else
2321 2373 $valor = "nenhum";
2322 2374 if(!isset($indices[$valor]))
2323 2375 {
2324   - $indices[$valor] = array($shp_index);
  2376 + $indices[$valor] = array($i);
2325 2377 }
2326 2378 else
2327   - $indices[$valor] = array_merge($indices[$valor],array($shp_index));
  2379 + $indices[$valor] = array_merge($indices[$valor],array($i));
2328 2380 }
2329 2381 //var_dump($indices);
2330 2382 //
... ... @@ -2335,7 +2387,10 @@ $locaplic - Localização do I3geo
2335 2387 {
2336 2388 foreach ($i as $indice)
2337 2389 {
2338   - $shape = $this->layer->getfeature($indice,-1);
  2390 + if($this->v == 6)
  2391 + {$shape = $this->layer->getShape($this->layer->getResult($indice));}
  2392 + else
  2393 + {$shape = $this->layer->getfeature($indice,-1);}
2339 2394 if($item != "")
2340 2395 $valor = $shape->values[$item];
2341 2396 else
... ... @@ -2344,7 +2399,7 @@ $locaplic - Localização do I3geo
2344 2399 {$dissolve[$valor] = $shape;}
2345 2400 else
2346 2401 {
2347   - $dissolve[$valor] = $shape->union_geos($dissolve[$valor]);
  2402 + $dissolve[$valor] = $shape->union($dissolve[$valor]);
2348 2403 }
2349 2404 }
2350 2405 }
... ... @@ -2739,9 +2794,13 @@ function gravaCoordenadasPt($tema,$limitepontos=&quot;TRUE&quot;,$extendelimite)
2739 2794 }
2740 2795 for ($i = 0; $i < $res_count; ++$i)
2741 2796 {
2742   - $result = $layerPt->getResult($i);
2743   - $shp_index = $result->shapeindex;
2744   - $shape = $layerPt->getfeature($shp_index,-1);
  2797 + if($this->v == 6)
  2798 + {$shape = $layerPt->getShape($layerPt->getResult($i));}
  2799 + else{
  2800 + $result = $layerPt->getResult($i);
  2801 + $shp_index = $result->shapeindex;
  2802 + $shape = $layerPt->getfeature($shp_index,-1);
  2803 + }
2745 2804 $lineo = $shape->line(0);
2746 2805 $pt = $lineo->point(0);
2747 2806 if (($prjTema != "") && ($prjMapa != $prjTema))
... ...
classesphp/classe_atributos.php
... ... @@ -74,7 +74,13 @@ class Atributos
74 74  
75 75 Objeto projection original do mapa. Obtido apenas na interface Googlemaps
76 76 */
77   - public $projO;
  77 + public $projO;
  78 + /*
  79 + Variavel: $v
  80 +
  81 + Versão atual do Mapserver (primeiro dígito)
  82 + */
  83 + public $v;
78 84 /*
79 85 Function: __construct
80 86  
... ... @@ -100,6 +106,8 @@ $ext - (opcional) extensão geográfica que será aplicada ao mapa
100 106 include_once($locaplic."/funcoes_gerais.php");
101 107 else
102 108 include_once("funcoes_gerais.php");
  109 + $this->v = versao();
  110 + $this->v = $this->v["principal"];
103 111 if($map_file != ""){
104 112 $this->qyfile = str_replace(".map",".qy",$map_file);
105 113 $this->locaplic = $locaplic;
... ... @@ -195,17 +203,20 @@ $registro - Índice do registro que será consultado.
195 203 $this->layer->setfilter("");
196 204 $ext = "";
197 205 //procura o registro e pega a extensão geográfica
198   - if (@$this->layer->open() == MS_SUCCESS)
199   - {
200   - $items = pegaItens($this->layer);
201   - if (@$this->layer->queryByrect($this->mapa->extent) == MS_SUCCESS)
  206 + if($this->v == 6)
  207 + {$shape = $this->layer->getShape(new resultObj($registro));}
  208 + else{
  209 + if (@$this->layer->open() == MS_SUCCESS)
202 210 {
203   - $this->layer->open();
204   - $shape = $this->layer->getfeature($registro,-1);
205   - $fechou = $this->layer->close();
206   - $ext = $this->extensaoShape($shape);
207   - }
  211 + if (@$this->layer->queryByrect($this->mapa->extent) == MS_SUCCESS)
  212 + {
  213 + $this->layer->open();
  214 + $shape = $this->layer->getfeature($registro,-1);
  215 + $fechou = $this->layer->close();
  216 + }
  217 + }
208 218 }
  219 + $ext = $this->extensaoShape($shape);
209 220 return($ext);
210 221 }
211 222 /*
... ... @@ -268,11 +279,15 @@ $tipo - Tipo de busca brasil|null
268 279 for ($i = 0; $i < $res_count; ++$i)
269 280 {
270 281 $valitem = array();
271   - foreach ($items as $item)
272   - {
  282 + if($this->v == 6)
  283 + {$shape = $this->layer->getShape($this->layer->getResult($i));}
  284 + else{
273 285 $result = $this->layer->getResult($i);
274 286 $shp_index = $result->shapeindex;
275   - $shape = $this->layer->getfeature($shp_index,-1);
  287 + $shape = $this->layer->getfeature($shp_index,-1);
  288 + }
  289 + foreach ($items as $item)
  290 + {
276 291 $v = trim($shape->values[$item]);
277 292 $v = $this->converte($v);
278 293 $valitem[] = $v;
... ... @@ -341,16 +356,22 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona
341 356 for ($i = $inicio; $i < $res_count; ++$i)
342 357 {
343 358 $valitem = array();
  359 + if($this->v == 6){
  360 + $shape = $this->layer->getShape($this->layer->getResult($i));
  361 + $indx = $shape->index;
  362 + }
  363 + else{
  364 + $result = $this->layer->getResult($i);
  365 + $indx = $result->shapeindex;
  366 + $shape = $this->layer->getfeature($indx,-1);
  367 + }
344 368 foreach ($items as $item)
345 369 {
346   - $result = $this->layer->getResult($i);
347   - $shp_index = $result->shapeindex;
348   - $shape = $this->layer->getfeature($shp_index,-1);
349 370 $valori = trim($shape->values[$item]);
350 371 $valori = $this->converte($valori);
351 372 $valitem[] = array("item"=>$item,"valor"=>$valori);
352 373 }
353   - $registros[] = array("indice"=>$shp_index,"valores"=>$valitem,"status"=>$chk);
  374 + $registros[] = array("indice"=>$indx,"valores"=>$valitem,"status"=>$chk);
354 375 }
355 376 $resultadoFinal[] = array("registros"=>$registros);
356 377 }
... ... @@ -378,11 +399,17 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona
378 399 for ($i = $inicio; $i < $res_count; ++$i)
379 400 {
380 401 $valitem = array();
381   - foreach ($items as $item)
382   - {
  402 + if($this->v == 6){
  403 + $shape = $this->layer->getShape($this->layer->getResult($i));
  404 + $indx = $shape->index;
  405 + }
  406 + else{
383 407 $result = $this->layer->getResult($i);
384   - $shp_index = $result->shapeindex;
385   - $shape = $this->layer->getfeature($shp_index,-1);
  408 + $indx = $result->shapeindex;
  409 + $shape = $this->layer->getfeature($indx,-1);
  410 + }
  411 + foreach ($items as $item)
  412 + {
386 413 $valori = "";
387 414 if(@$shape->values[$item])
388 415 {
... ... @@ -392,9 +419,9 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona
392 419 $valitem[] = array("item"=>$item,"valor"=>$valori);
393 420 }
394 421 //if (in_array($shp_index,$shp_atual))
395   - if(isset($shp_atual[$shp_index]))
  422 + if(isset($shp_atual[$indx]))
396 423 {$chk = "CHECKED";}
397   - $registros[] = array("indice"=>$shp_index,"valores"=>$valitem,"status"=>$chk);
  424 + $registros[] = array("indice"=>$indx,"valores"=>$valitem,"status"=>$chk);
398 425 $chk = "";
399 426 }
400 427 $this->layer->close();
... ... @@ -533,9 +560,13 @@ Include:
533 560 //pega os valores
534 561 for ($i = 0; $i < $res_count; ++$i)
535 562 {
536   - $result = $this->layer->getResult($i);
537   - $shp_index = $result->shapeindex;
538   - $shape = $this->layer->getfeature($shp_index,-1);
  563 + if($this->v == 6)
  564 + {$shape = $this->layer->getShape($this->layer->getResult($i));}
  565 + else{
  566 + $result = $this->layer->getResult($i);
  567 + $shp_index = $result->shapeindex;
  568 + $shape = $this->layer->getfeature($shp_index,-1);
  569 + }
539 570 $v = $shape->values[$item];
540 571 $valores[] = $v;
541 572 }
... ... @@ -1063,9 +1094,8 @@ $listaDeTemas - (opcional) Lista com os códigos dos temas que serão identificado
1063 1094 for ($i = 0; $i < $res_count; ++$i)
1064 1095 {
1065 1096 $valori = array();
1066   - $result = $layer->getResult($i);
1067   - $shp_index = $result->shapeindex;
1068   - $shape = $layer->getfeature($shp_index,-1);
  1097 + $shape = $layer->getShape($layer->getResult($i));
  1098 +
1069 1099 if ($tiporetorno == "shape")
1070 1100 {
1071 1101 $layer->close();
... ... @@ -1322,9 +1352,13 @@ $listaDeTemas - (opcional) Lista com os códigos dos temas que serão identificado
1322 1352 for ($i = 0; $i < $res_count; ++$i)
1323 1353 {
1324 1354 $valori = array();
1325   - $result = $layer->getResult($i);
1326   - $shp_index = $result->shapeindex;
1327   - $shape = $layer->getfeature($shp_index,-1);
  1355 + if($this->v == 6)
  1356 + {$shape = $layer->getShape($layer->getResult($i));}
  1357 + else{
  1358 + $result = $layer->getResult($i);
  1359 + $shp_index = $result->shapeindex;
  1360 + $shape = $layer->getfeature($shp_index,-1);
  1361 + }
1328 1362 $conta = 0;
1329 1363 //var_dump($itens);exit;
1330 1364 if($tiporetorno == "shape" || $tiporetorno == "googlerelevo"){
... ...
classesphp/classe_legenda.php
... ... @@ -513,20 +513,21 @@ String no formato HTML com as imagens dos símbolos
513 513 */
514 514 function listaSimbolos($tipo,$dir_tmp,$imgdir,$onclick,$tamanho=8,$width=1)
515 515 {
  516 + $versao = versao();
  517 + $versao = $versao["principal"];
516 518 //error_reporting(E_ALL);
517 519 if ($tipo == 3){$tipo = 2;} //tipo raster
518 520 if($imgdir == "")
519 521 {$dir = $dir_tmp;}
520 522 else
521 523 {$dir = $dir_tmp."/".$imgdir;}
522   -
523 524 if (!file_exists($dir."/simbolos".$tipo.".inc"))
524 525 {
525 526 $f = fopen($dir."/simbolos".$tipo.".inc","w");
526   - if ($tipo == 2){$t="simpol.map";}
527   - if ($tipo == 0){$t="simpt.map";}
  527 + if ($tipo == 2){$t="simpolv".$versao.".map";}
  528 + if ($tipo == 0){$t="simptv".$versao.".map";}
528 529 if ($tipo == 1){
529   - $t="simlin.map";
  530 + $t="simlinv".$versao.".map";
530 531 $tamanho = $tamanho / 4;
531 532 }
532 533 if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))
... ... @@ -534,19 +535,22 @@ String no formato HTML com as imagens dos símbolos
534 535 else
535 536 {$mapatemp = ms_newMapObj($this->localaplicacao."/aplicmap/".$t);}
536 537 $ins = "";
537   - $ns = $mapatemp->getnumsymbols();
  538 +
538 539 $l = $mapatemp->getlayer(0);
539   - $novoss = dirname($this->mapa->symbolsetfilename)."/".basename($mapatemp->symbolsetfilename);
  540 + $novoss = dirname($this->mapa->symbolsetfilename)."\\".basename($mapatemp->symbolsetfilename);
540 541 $this->mapa->setsymbolset($novoss);
  542 + $ns = $this->mapa->getnumsymbols();
541 543 for ($i=0;$i < $ns;++$i)
542 544 {
543 545 $oSymbol = $this->mapa->getSymbolObjectById($i);
544 546 $nomes = $oSymbol->name;
  547 + if($nomes == "")
  548 + {$nomes = $i;}
545 549 $adiciona = ms_newLayerObj($this->mapa, $l);
546 550 $nomel = $l->name;
547 551 $tematemp= $this->mapa->getlayerbyname($nomel);
548 552 $c = $tematemp->getClass(0);
549   - $e = $c->getstyle(0);
  553 + $e = $c->getstyle(0);
550 554 $e->set("symbolname",$nomes);
551 555 $e->set("size",$tamanho);
552 556 $e->set("width",$width);
... ...
classesphp/classe_mapa.php
... ... @@ -59,7 +59,12 @@ class Mapa
59 59 Nome do arquivo de seleção (.qy)
60 60 */
61 61 public $qyfile;
  62 + /*
  63 + Variavel: $v
62 64  
  65 + Versão atual do Mapserver (primeiro dígito)
  66 + */
  67 + public $v;
63 68 /*
64 69 Function: __construct
65 70  
... ... @@ -77,6 +82,8 @@ $map_file - Endereço do mapfile no servidor.
77 82 include_once($locaplic."/funcoes_gerais.php");
78 83 else
79 84 include_once("funcoes_gerais.php");
  85 + $this->v = versao();
  86 + $this->v = $this->v["principal"];
80 87 $this->qyfile = str_replace(".map",".qy",$map_file);
81 88 $this->locaplic = $locaplic;
82 89 if(!file_exists($map_file))
... ... @@ -1677,7 +1684,10 @@ $arq - Nome do shape file.
1677 1684 if (file_exists($arq))
1678 1685 {
1679 1686 $s = ms_newShapefileObj($arq,-1);
1680   - $shape = $s->getShape(0);
  1687 + if($this->v == 6)
  1688 + {$shape = $s->getshape(new resultObj(0));}
  1689 + else
  1690 + {$shape = $s->getshape(0);}
1681 1691 $t = $shape->type;
1682 1692 $tipo = MS_LAYER_POLYGON;
1683 1693 if ($t == 0)
... ...
classesphp/classe_selecao.php
... ... @@ -73,7 +73,13 @@ class Selecao
73 73  
74 74 Objeto projection original do mapa. Obtido apenas na interface Googlemaps
75 75 */
76   - public $projO;
  76 + public $projO;
  77 + /*
  78 + Variavel: $v
  79 +
  80 + Versão atual do Mapserver (primeiro dígito)
  81 + */
  82 + public $v;
77 83 /*
78 84 Function: __construct
79 85  
... ... @@ -92,6 +98,12 @@ $ext - extensão geográfica do mapa
92 98  
93 99 function __construct($map_file,$tema="",$ext="")
94 100 {
  101 + if(file_exists($locaplic."/funcoes_gerais.php"))
  102 + include_once($locaplic."/funcoes_gerais.php");
  103 + else
  104 + include_once("funcoes_gerais.php");
  105 + $this->v = versao();
  106 + $this->v = $this->v["principal"];
95 107 $this->qyfile = str_replace(".map",".qy",$map_file);
96 108 if($tema != "")
97 109 {$this->qyfileTema = dirname($map_file)."/".$tema.".php";}
... ... @@ -271,9 +283,13 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa|novo
271 283 $res_count = $layero->getNumresults();
272 284 for ($i = 0; $i < $res_count; ++$i)
273 285 {
274   - $result = $layero->getResult($i);
275   - $s = $result->shapeindex;
276   - $sh = $layero->getfeature($s,-1);
  286 + if($this->v == 6)
  287 + {$sh = $layero->getShape($layero->getResult($i));}
  288 + else{
  289 + $result = $layero->getResult($i);
  290 + $s = $result->shapeindex;
  291 + $sh = $layero->getfeature($s,-1);
  292 + }
277 293 $tiposh = $sh->type;
278 294 if ($tiposh == 2)
279 295 {$ident = @$this->layer->querybyshape($sh);}
... ... @@ -326,9 +342,11 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa|novo
326 342 $conta = $layero->getNumresults();
327 343 for ($k = 0; $k < $conta; $k++)
328 344 {
329   - if (@$layero->getfeature($k,-1))
330   - {
331   - $s = $layero->getfeature($k,-1);
  345 + if($this->v == 6)
  346 + {$s = @$layero->getShape($layero->getResult($k));}
  347 + else
  348 + {$s = @$layero->getfeature($k,-1);}
  349 + if($s){
332 350 if ($s->type == 2)
333 351 {
334 352 $this->layer->querybyshape($s);
... ...
classesphp/classe_shp.php
... ... @@ -66,6 +66,12 @@ class SHP
66 66 Indica se a biblioteca dbase está carregada
67 67 */
68 68 protected $dbaseExiste;
  69 + /*
  70 + Variavel: $v
  71 +
  72 + Versão atual do Mapserver (primeiro dígito)
  73 + */
  74 + public $v;
69 75  
70 76 /*
71 77 function: __construct
... ... @@ -82,7 +88,13 @@ $ext - extensao geográfica que será aplicada ao mapa
82 88 */
83 89 function __construct($map_file,$tema="",$locaplic="",$ext="")
84 90 {
85   - //error_reporting(E_ALL);
  91 + if (!function_exists('ms_newMapObj')) {return false;}
  92 + if(file_exists($locaplic."/funcoes_gerais.php"))
  93 + include_once($locaplic."/funcoes_gerais.php");
  94 + else
  95 + include_once("funcoes_gerais.php");
  96 + $this->v = versao();
  97 + $this->v = $this->v["principal"];
86 98 $this->dbaseExiste = false;
87 99 if(function_exists("dbase_create"))
88 100 {$this->dbaseExiste = true;}
... ... @@ -383,9 +395,13 @@ array - xy
383 395 $xy = array();
384 396 for ($i = 0; $i < $res_count; ++$i)
385 397 {
386   - $result = $this->layer->getResult($i);
387   - $shp_index = $result->shapeindex;
388   - $shape = $this->layer->getfeature($shp_index,-1);
  398 + if($this->v == 6)
  399 + {$shape = $this->layer->getShape($this->layer->getResult($i));}
  400 + else{
  401 + $result = $this->layer->getResult($i);
  402 + $shp_index = $result->shapeindex;
  403 + $shape = $this->layer->getfeature($shp_index,-1);
  404 + }
389 405 $nlinhas = $shape->numlines;
390 406 for($j = 0;$j < $nlinhas; ++$j){
391 407 $lin = $shape->line($j);
... ... @@ -415,10 +431,13 @@ array(&quot;layerprj&quot;=&gt;$xylayer,&quot;mapprj&quot;=&gt;$xymapa)
415 431 $sopen = $this->layer->open();
416 432 if($sopen == MS_FAILURE){return "erro";}
417 433 $xy = array();
418   -
419   - $result = $this->layer->getResult($res_count - 1);
420   - $shp_index = $result->shapeindex;
421   - $shape = $this->layer->getfeature($shp_index,-1);
  434 + if($this->v == 6)
  435 + {$shape = $this->layer->getShape($this->layer->getshape(new resultObj($res_count - 1)));}
  436 + else{
  437 + $result = $this->layer->getResult($res_count - 1);
  438 + $shp_index = $result->shapeindex;
  439 + $shape = $this->layer->getfeature($shp_index,-1);
  440 + }
422 441 $lin = $shape->line(0);
423 442 $pt = $lin->point(0);
424 443 $this->layer->close();
... ...
classesphp/classe_temas.php
... ... @@ -86,6 +86,12 @@ class Temas
86 86 Nome do arquivo de seleção (.qy)
87 87 */
88 88 public $qyfile;
  89 + /*
  90 + Variavel: $v
  91 +
  92 + Versão atual do Mapserver (primeiro dígito)
  93 + */
  94 + public $v;
89 95 /*
90 96 function __construct
91 97  
... ... @@ -109,6 +115,8 @@ $ext - (opcional) extensão geográfica que será aplicada ao mapa
109 115 include_once($locaplic."/funcoes_gerais.php");
110 116 else
111 117 include_once("funcoes_gerais.php");
  118 + $this->v = versao();
  119 + $this->v = $this->v["principal"];
112 120 $this->locaplic = $locaplic;
113 121 if($map_file != "")
114 122 {
... ... @@ -783,9 +791,13 @@ $nome - nome que será dado a geometria
783 791 for ($i = 0; $i < $res_count; ++$i)
784 792 {
785 793 $valitem = array();
786   - $result = $this->layer->getResult($i);
787   - $shp_index = $result->shapeindex;
788   - $shape = $this->layer->getfeature($shp_index,-1);
  794 + if($this->v == 6)
  795 + {$shape = $this->layer->getShape($this->layer->getResult($i));}
  796 + else{
  797 + $result = $this->layer->getResult($i);
  798 + $shp_index = $result->shapeindex;
  799 + $shape = $this->layer->getfeature($shp_index,-1);
  800 + }
789 801 foreach ($items as $item)
790 802 {
791 803 $v = trim($shape->values[$item]);
... ... @@ -1006,28 +1018,38 @@ Calcula a extensão geográfica dos elementos selecionados de um tema e ajusta o m
1006 1018 $res_count = $this->layer->getNumresults();
1007 1019 if($res_count > 0)
1008 1020 {
1009   - $xmin = array();
1010   - $xmax = array();
1011   - $ymin = array();
1012   - $ymax = array();
1013   - for ($i = 0; $i < $res_count; ++$i)
1014   - {
1015   - $valitem = array();
1016   - $result = $this->layer->getResult($i);
1017   - $shp_index = $result->shapeindex;
1018   - $shape = $this->layer->getfeature($shp_index,-1);
1019   - $bound = $shape->bounds;
1020   - $xmin[] = $bound->minx;
1021   - $xmax[] = $bound->maxx;
1022   - $ymin[] = $bound->miny;
1023   - $ymax[] = $bound->maxy;
  1021 + $versao = versao();
  1022 + if($versao["principal"] == 6){
  1023 + $ret = $this->layer->getResultsBounds();
  1024 + }
  1025 + else{
  1026 + $xmin = array();
  1027 + $xmax = array();
  1028 + $ymin = array();
  1029 + $ymax = array();
  1030 + for ($i = 0; $i < $res_count; ++$i)
  1031 + {
  1032 + $valitem = array();
  1033 + if($this->v == 6)
  1034 + {$shape = $this->layer->getShape($this->layer->getResult($i));}
  1035 + else{
  1036 + $result = $this->layer->getResult($i);
  1037 + $shp_index = $result->shapeindex;
  1038 + $shape = $this->layer->getfeature($shp_index,-1);
  1039 + }
  1040 + $bound = $shape->bounds;
  1041 + $xmin[] = $bound->minx;
  1042 + $xmax[] = $bound->maxx;
  1043 + $ymin[] = $bound->miny;
  1044 + $ymax[] = $bound->maxy;
  1045 + }
  1046 + $ret = ms_newRectObj();
  1047 + $ret->set("minx",min($xmin));
  1048 + $ret->set("miny",min($ymin));
  1049 + $ret->set("maxx",max($xmax));
  1050 + $ret->set("maxy",max($ymax));
1024 1051 }
1025 1052 $this->layer->close();
1026   - $ret = ms_newRectObj();
1027   - $ret->set("minx",min($xmin));
1028   - $ret->set("miny",min($ymin));
1029   - $ret->set("maxx",max($xmax));
1030   - $ret->set("maxy",max($ymax));
1031 1053 if (($prjTema != "") && ($prjMapa != $prjTema))
1032 1054 {
1033 1055 $projInObj = ms_newprojectionobj($prjTema);
... ...
classesphp/funcoes_gerais.php
... ... @@ -1105,6 +1105,8 @@ function pegaValores($mapa,$layer,$item,$numerico=false,$ignorar=&quot;&quot;)
1105 1105 {
1106 1106 $layer->set("template","none.htm");
1107 1107 $layer->setfilter("");
  1108 + $versao = versao();
  1109 + $versao = $versao["principal"];
1108 1110 if (@$layer->queryByrect($mapa->extent) == MS_SUCCESS)
1109 1111 {
1110 1112 $sopen = $layer->open();
... ... @@ -1113,9 +1115,13 @@ function pegaValores($mapa,$layer,$item,$numerico=false,$ignorar=&quot;&quot;)
1113 1115 $valitem = array();
1114 1116 for ($i=0;$i<$res_count;++$i)
1115 1117 {
1116   - $result = $layer->getResult($i);
1117   - $shp_index = $result->shapeindex;
1118   - $shape = $layer->getfeature($shp_index,-1);
  1118 + if($versao == 6)
  1119 + {$shape = $layer->getShape($layer->getResult($i));}
  1120 + else{
  1121 + $result = $layer->getResult($i);
  1122 + $shp_index = $result->shapeindex;
  1123 + $shape = $layer->getfeature($shp_index,-1);
  1124 + }
1119 1125 $v = trim($shape->values[$item]);
1120 1126 if ($numerico)
1121 1127 {
... ... @@ -1173,7 +1179,8 @@ Retorno:
1173 1179 */
1174 1180 function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$chaves=false,$centroide=false)
1175 1181 {
1176   - //error_reporting(E_ALL);
  1182 + $versao = versao();
  1183 + $versao = $versao["principal"];
1177 1184 $prjMapa = $mapa->getProjection();
1178 1185 $prjTema = $layer->getProjection();
1179 1186 $layer->set("template","none.htm");
... ... @@ -1204,12 +1211,18 @@ function pegaValoresM($mapa,$layer,$itens,$exclui=&quot;nulo&quot;,$selecionados=&quot;nao&quot;,$ch
1204 1211  
1205 1212 for ($i=0;$i<$res_count;++$i)
1206 1213 {
1207   - $result = $layer->getResult($i);
1208   - $shp_index = $result->shapeindex;
  1214 + if($versao == 6){
  1215 + $shape = $layer->getShape($layer->getResult($i));
  1216 + $shp_index = $shape->index;
  1217 + }
  1218 + else{
  1219 + $result = $layer->getResult($i);
  1220 + $shp_index = $result->shapeindex;
  1221 + $shape = $layer->getfeature($shp_index,-1);
  1222 + }
1209 1223 if (($selecionados == "sim") && (array_search($shp_index,$indicesel) === FALSE))
1210 1224 {continue;}
1211 1225 $considera = "sim";
1212   - $shape = $layer->getfeature($shp_index,-1);
1213 1226 //verifica se no registro deve ser considerado
1214 1227 if ($exclui != "nulo")
1215 1228 {
... ... @@ -1804,6 +1817,8 @@ Retorno:
1804 1817 */
1805 1818 function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE)
1806 1819 {
  1820 + $versao = versao();
  1821 + $versao = $versao["principal"];
1807 1822 //para manipular dbf
1808 1823 if(file_exists($locaplic."/pacotes/phpxbase/api_conversion.php"))
1809 1824 include_once($locaplic."/pacotes/phpxbase/api_conversion.php");
... ... @@ -1842,10 +1857,14 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE)
1842 1857 dbase_add_record($db,$reg);
1843 1858 dbase_close($db);
1844 1859 }
1845   - $s = $layer->getfeature(0,-1);
1846   - $result = $layer->getResult(0);
1847   - $shpi = $result->shapeindex;
1848   - $shape = $layer->getfeature($shpi,-1);
  1860 + if($versao == 6)
  1861 + {$shape = $layer->getshape(new resultObj(0));}
  1862 + else{
  1863 + $s = $layer->getfeature(0,-1);
  1864 + $result = $layer->getResult(0);
  1865 + $shpi = $result->shapeindex;
  1866 + $shape = $layer->getfeature($shpi,-1);
  1867 + }
1849 1868 $novoshpf = ms_newShapefileObj($nomeshp.".shp", -2);
1850 1869 $novoshpf->addShape($shape);
1851 1870 $novoshpf->free();
... ... @@ -1886,9 +1905,13 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE)
1886 1905 if($sopen == MS_FAILURE){return "erro";}
1887 1906 for ($i = 0; $i < $res_count; ++$i)
1888 1907 {
1889   - $result = $layer->getResult($i);
1890   - $shp_index = $result->shapeindex;
1891   - $shape = $layer->getfeature($shp_index,-1);
  1908 + if($versao == 6)
  1909 + {$shape = $layer->getShape($layer->getResult($i));}
  1910 + else{
  1911 + $result = $layer->getResult($i);
  1912 + $shp_index = $result->shapeindex;
  1913 + $shape = $layer->getfeature($shp_index,-1);
  1914 + }
1892 1915 foreach ($items as $ni)
1893 1916 {
1894 1917 $vreg = $shape->values[$ni];
... ...
classesphp/mapa_googlemaps.php
... ... @@ -263,10 +263,12 @@ if(trim($_GET[&quot;TIPOIMAGEM&quot;]) != &quot;&quot; &amp;&amp; trim($_GET[&quot;TIPOIMAGEM&quot;]) != &quot;nenhum&quot;)
263 263 }
264 264 else{
265 265 if($cache == true)
266   - {salvaCacheImagem($_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);}
  266 + {$nomer = salvaCacheImagem($_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);}
  267 + else{
  268 + $nomer = ($img->imagepath)."imgtemp".nomeRandomico().".png";
  269 + $img->saveImage($nomer);
  270 + }
267 271 ob_clean();
268   - $nomer = ($img->imagepath)."imgtemp".nomeRandomico().".png";
269   - $img->saveImage($nomer);
270 272 $img = imagecreatefrompng($nomer);
271 273 imagealphablending($img, false);
272 274 imagesavealpha($img, true);
... ... @@ -286,6 +288,7 @@ function salvaCacheImagem($bbox,$layer,$map,$w,$h){
286 288 $nome = $nomedir."/".$w.$h.$bbox.".png";
287 289 if(!file_exists($nome))
288 290 {$img->saveImage($nome);}
  291 + return $nome;
289 292 }
290 293 function carregaCacheImagem($bbox,$layer,$map,$w,$h){
291 294 if($layer == "copyright" || $layer == "")
... ...
classesphp/mapa_inicia.php
... ... @@ -223,16 +223,18 @@ function iniciaMapa()
223 223 $l->set("status",MS_DELETE);
224 224 }
225 225 $of = $mf->outputformat;
  226 + $of->set("driver","GD/PNG");
  227 + /*
226 228 $versao = versao();
227 229 if($versao["principal"] == 6)
228 230 {$of->set("driver","GD/PNG");}
229 231 else
230 232 {$of->set("driver","AGG/PNG");}
231   -
232   -
  233 + */
233 234 $temp = $mf->scalebar;
234 235 $temp->set("status",MS_OFF);
235 236 $mf->save($nomefundo);
  237 + //
236 238 $temp = $m->mapa->scalebar;
237 239 $temp->set("status",MS_OFF);
238 240 $of = $m->mapa->outputformat;
... ...
classesphp/mapa_openlayers.php
... ... @@ -255,15 +255,16 @@ if(trim($_GET[&quot;TIPOIMAGEM&quot;]) != &quot;&quot; &amp;&amp; trim($_GET[&quot;TIPOIMAGEM&quot;]) != &quot;nenhum&quot;)
255 255 }
256 256 else{
257 257 if($cache == true)
258   - {salvaCacheImagem($_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);}
  258 + {$nomer = salvaCacheImagem($_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);}
  259 + else{
  260 + $nomer = ($img->imagepath)."imgtemp".nomeRandomico().".png";
  261 + $img->saveImage($nomer);
  262 + }
259 263 ob_clean();
260   - $nomer = ($img->imagepath)."imgtemp".nomeRandomico().".png";
261   - $img->saveImage($nomer);
262 264 $img = imagecreatefrompng($nomer);
263 265 imagealphablending($img, false);
264 266 imagesavealpha($img, true);
265 267 ob_clean();
266   -
267 268 echo header("Content-type: image/png \n\n");
268 269 imagepng($img);
269 270 imagedestroy($img);
... ... @@ -284,6 +285,7 @@ function salvaCacheImagem($bbox,$layer,$map,$w,$h){
284 285 $img->saveImage($nome);
285 286 chmod($nome,0777);
286 287 }
  288 + return $nome;
287 289 }
288 290 function carregaCacheImagem($bbox,$layer,$map,$w,$h){
289 291 if($layer == "copyright" || $layer == "")
... ...