From 4ea8405390c9cccffe9a4faac7fcb1c751baf421 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Sat, 10 Sep 2011 00:52:36 +0000 Subject: [PATCH] Adaptações dos códigos para a versão 6 do Mapserver --- classesphp/classe_analise.php | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------- classesphp/classe_atributos.php | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------- classesphp/classe_legenda.php | 18 +++++++++++------- classesphp/classe_mapa.php | 12 +++++++++++- classesphp/classe_selecao.php | 32 +++++++++++++++++++++++++------- classesphp/classe_shp.php | 35 +++++++++++++++++++++++++++-------- classesphp/classe_temas.php | 68 +++++++++++++++++++++++++++++++++++++++++++++----------------------- classesphp/funcoes_gerais.php | 51 +++++++++++++++++++++++++++++++++++++-------------- classesphp/mapa_googlemaps.php | 9 ++++++--- classesphp/mapa_inicia.php | 6 ++++-- classesphp/mapa_openlayers.php | 10 ++++++---- 11 files changed, 338 insertions(+), 142 deletions(-) diff --git a/classesphp/classe_analise.php b/classesphp/classe_analise.php index 3b758b4..d523cc4 100644 --- a/classesphp/classe_analise.php +++ b/classesphp/classe_analise.php @@ -74,6 +74,12 @@ class Analise */ public $qyfile; /* + Variavel: $v + + Versão atual do Mapserver (primeiro dígito) + */ + public $v; + /* Variavel: $dbaseExiste Indica se a biblioteca dbase está carregada @@ -100,6 +106,8 @@ $ext - Extensão geográfica do mapa include_once($locaplic."/funcoes_gerais.php"); else include_once("funcoes_gerais.php"); + $this->v = versao(); + $this->v = $this->v["principal"]; $this->dbaseExiste = false; if(function_exists("dbase_create")) {$this->dbaseExiste = true;} @@ -1026,9 +1034,13 @@ $locaplic - Localização do I3geo. $spts = array(); for ($i = 0; $i < $res_count; ++$i) { - $result = $layerPt->getResult($i); - $shp_index = $result->shapeindex; - $shape = $layerPt->getfeature($shp_index,-1); + if($this->v == 6) + {$shape = $layerPt->getShape($layerPt->getResult($i));} + else{ + $result = $layerPt->getResult($i); + $shp_index = $result->shapeindex; + $shape = $layerPt->getfeature($shp_index,-1); + } $spts[] = $shape; } $layerPt->close(); @@ -1098,10 +1110,13 @@ $locaplic - Localização do I3geo. if($sopen == MS_FAILURE){return "erro";} if ($res_count > 0 && $layer->getResult(0) !== FALSE) { - $result = $layer->getResult(0); - $shp_index = $result->shapeindex; - - $shape = $layer->getfeature($shp_index,-1); + if($this->v == 6) + {$shape = $layer->getShape($layer->getResult(0));} + else{ + $result = $layer->getResult(0); + $shp_index = $result->shapeindex; + $shape = $layer->getfeature($shp_index,-1); + } foreach ($itens as $item) {$reg[] = $this->truncaS($shape->values[$item]);} } @@ -1190,9 +1205,13 @@ function distanciaptpt($temaorigem,$temadestino,$temaoverlay,$locaplic,$itemorig $res_count = $layerorigem->getNumresults(); for ($i = 0; $i < $res_count; ++$i) { - $result = $layerorigem->getResult($i); - $shp_index = $result->shapeindex; - $shapesorigem[] = $layerorigem->getshape(-1, $shp_index); + if($this->v == 6) + {$shapesorigem[] = $layerorigem->getShape($layerorigem->getResult($i));} + else{ + $result = $layerorigem->getResult($i); + $shp_index = $result->shapeindex; + $shapesorigem[] = $layerorigem->getshape(-1, $shp_index); + } } $layerorigem->close(); $layeroverlay->set("tolerance",0); @@ -1212,9 +1231,13 @@ function distanciaptpt($temaorigem,$temadestino,$temaoverlay,$locaplic,$itemorig for ($i = 0; $i < $res_count; ++$i) { - $result = $layerdestino->getResult($i); - $shp_index = $result->shapeindex; - $shapesdestino[] = $layerdestino->getshape(-1, $shp_index); + if($this->v == 6) + {$shapesdestino[] = $layerdestino->getShape($layerdestino->getResult($i));} + else{ + $result = $layerdestino->getResult($i); + $shp_index = $result->shapeindex; + $shapesdestino[] = $layerdestino->getshape(-1, $shp_index); + } } $layerdestino->close(); $rect = $this->mapa->extent; @@ -1332,9 +1355,13 @@ nome do layer criado com o buffer. //pega um shape especifico for ($i = 0; $i < $res_count; ++$i) { - $result = $this->layer->getResult($i); - $shp_index = $result->shapeindex; - $listaShapes[] = $this->layer->getfeature($shp_index,-1); + if($this->v == 6) + {$listaShapes[] = $this->layer->getShape($this->layer->getResult($i));} + else{ + $result = $this->layer->getResult($i); + $shp_index = $result->shapeindex; + $listaShapes[] = $this->layer->getfeature($shp_index,-1); + } } $fechou = $this->layer->close(); } @@ -1369,7 +1396,7 @@ nome do layer criado com o buffer. { $ns = $buffers[0]; for($s=1;$s < count($buffers);$s++) - {$ns = $ns->union_geos($buffers[$s]);} + {$ns = $ns->union($buffers[$s]);} $buffers = array($ns); $shapes = array($shapes[0]); } @@ -1460,9 +1487,13 @@ $item {string} - (opcional) Item q será utilizado para ponderar os valores. $ys = 0; for ($i = 0; $i < $res_count; ++$i) { - $result = $this->layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $this->layer->getfeature($shp_index,-1); + if($this->v == 6) + {$shape = $this->layer->getShape($this->layer->getResult($i));} + else{ + $result = $this->layer->getResult($i); + $shp_index = $result->shapeindex; + $shape = $this->layer->getfeature($shp_index,-1); + } if($item != "") {$pondera = $shape->values[$item];} $pt = $shape->line(0)->point(0); @@ -1551,9 +1582,13 @@ $locaplic - Localização do I3geo. //pega um shape especifico for ($i = 0; $i < $res_count; ++$i) { - $result = $this->layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $this->layer->getfeature($shp_index,-1); + if($this->v == 6) + {$shape = $this->layer->getShape($this->layer->getResult($i));} + else{ + $result = $this->layer->getResult($i); + $shp_index = $result->shapeindex; + $shape = $this->layer->getfeature($shp_index,-1); + } $LineObj = ms_newLineObj(); $LineObj->add($shape->getCentroid()); $ShapeObj = ms_newShapeObj(MS_SHAPE_POINT); @@ -2121,9 +2156,13 @@ $locaplic - Localização do I3geo $res_count = $layerPo->getNumresults(); for ($i = 0; $i < $res_count; ++$i) { - $result = $layerPo->getResult($i); - $shp_index = $result->shapeindex; - $shape = $layerPo->getfeature($shp_index,-1); + if($this->v == 6) + {$shape = $layerPo->getShape($layerPo->getResult($i));} + else{ + $result = $layerPo->getResult($i); + $shp_index = $result->shapeindex; + $shape = $layerPo->getfeature($shp_index,-1); + } $novoreg = array(); foreach($itenspo as $ipo) {$novoreg[] = $shape->values[$ipo];} @@ -2182,9 +2221,15 @@ Salva o mapa acrescentando um novo layer com o resultado. $indices = array(); for ($i = 0; $i < $res_count; ++$i) { - $result = $this->layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $this->layer->getfeature($shp_index,-1); + if($this->v == 6){ + $shape = $this->layer->getShape($this->layer->getResult($i)); + $shp_index = $shape->index; + } + else{ + $result = $this->layer->getResult($i); + $shp_index = $result->shapeindex; + $shape = $this->layer->getfeature($shp_index,-1); + } if($item != "") $valor = $shape->values[$item]; else @@ -2202,7 +2247,10 @@ Salva o mapa acrescentando um novo layer com o resultado. { foreach ($i as $indice) { - $shape = $this->layer->getfeature($indice,-1); + if($this->v == 6) + {$shape = $this->layer->getShape($this->layer->getResult($indice));} + else + {$shape = $this->layer->getfeature($indice,-1);} if($item != "") $valor = $shape->values[$item]; else @@ -2224,7 +2272,7 @@ Salva o mapa acrescentando um novo layer com o resultado. } else { - $dissolve[$valor] = $shape->union_geos($dissolve[$valor]); + $dissolve[$valor] = $shape->union($dissolve[$valor]); } } } @@ -2312,19 +2360,23 @@ $locaplic - Localização do I3geo $indices = array(); for ($i = 0; $i < $res_count; ++$i) { - $result = $this->layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $this->layer->getfeature($shp_index,-1); + if($this->v == 6) + {$shape = $this->layer->getShape($this->layer->getResult($i));} + else{ + $result = $this->layer->getResult($i); + $shp_index = $result->shapeindex; + $shape = $this->layer->getfeature($shp_index,-1); + } if($item != "") $valor = $shape->values[$item]; else $valor = "nenhum"; if(!isset($indices[$valor])) { - $indices[$valor] = array($shp_index); + $indices[$valor] = array($i); } else - $indices[$valor] = array_merge($indices[$valor],array($shp_index)); + $indices[$valor] = array_merge($indices[$valor],array($i)); } //var_dump($indices); // @@ -2335,7 +2387,10 @@ $locaplic - Localização do I3geo { foreach ($i as $indice) { - $shape = $this->layer->getfeature($indice,-1); + if($this->v == 6) + {$shape = $this->layer->getShape($this->layer->getResult($indice));} + else + {$shape = $this->layer->getfeature($indice,-1);} if($item != "") $valor = $shape->values[$item]; else @@ -2344,7 +2399,7 @@ $locaplic - Localização do I3geo {$dissolve[$valor] = $shape;} else { - $dissolve[$valor] = $shape->union_geos($dissolve[$valor]); + $dissolve[$valor] = $shape->union($dissolve[$valor]); } } } @@ -2739,9 +2794,13 @@ function gravaCoordenadasPt($tema,$limitepontos="TRUE",$extendelimite) } for ($i = 0; $i < $res_count; ++$i) { - $result = $layerPt->getResult($i); - $shp_index = $result->shapeindex; - $shape = $layerPt->getfeature($shp_index,-1); + if($this->v == 6) + {$shape = $layerPt->getShape($layerPt->getResult($i));} + else{ + $result = $layerPt->getResult($i); + $shp_index = $result->shapeindex; + $shape = $layerPt->getfeature($shp_index,-1); + } $lineo = $shape->line(0); $pt = $lineo->point(0); if (($prjTema != "") && ($prjMapa != $prjTema)) diff --git a/classesphp/classe_atributos.php b/classesphp/classe_atributos.php index 30c34a9..4ef2af9 100644 --- a/classesphp/classe_atributos.php +++ b/classesphp/classe_atributos.php @@ -74,7 +74,13 @@ class Atributos Objeto projection original do mapa. Obtido apenas na interface Googlemaps */ - public $projO; + public $projO; + /* + Variavel: $v + + Versão atual do Mapserver (primeiro dígito) + */ + public $v; /* Function: __construct @@ -100,6 +106,8 @@ $ext - (opcional) extensão geográfica que será aplicada ao mapa include_once($locaplic."/funcoes_gerais.php"); else include_once("funcoes_gerais.php"); + $this->v = versao(); + $this->v = $this->v["principal"]; if($map_file != ""){ $this->qyfile = str_replace(".map",".qy",$map_file); $this->locaplic = $locaplic; @@ -195,17 +203,20 @@ $registro - Índice do registro que será consultado. $this->layer->setfilter(""); $ext = ""; //procura o registro e pega a extensão geográfica - if (@$this->layer->open() == MS_SUCCESS) - { - $items = pegaItens($this->layer); - if (@$this->layer->queryByrect($this->mapa->extent) == MS_SUCCESS) + if($this->v == 6) + {$shape = $this->layer->getShape(new resultObj($registro));} + else{ + if (@$this->layer->open() == MS_SUCCESS) { - $this->layer->open(); - $shape = $this->layer->getfeature($registro,-1); - $fechou = $this->layer->close(); - $ext = $this->extensaoShape($shape); - } + if (@$this->layer->queryByrect($this->mapa->extent) == MS_SUCCESS) + { + $this->layer->open(); + $shape = $this->layer->getfeature($registro,-1); + $fechou = $this->layer->close(); + } + } } + $ext = $this->extensaoShape($shape); return($ext); } /* @@ -268,11 +279,15 @@ $tipo - Tipo de busca brasil|null for ($i = 0; $i < $res_count; ++$i) { $valitem = array(); - foreach ($items as $item) - { + if($this->v == 6) + {$shape = $this->layer->getShape($this->layer->getResult($i));} + else{ $result = $this->layer->getResult($i); $shp_index = $result->shapeindex; - $shape = $this->layer->getfeature($shp_index,-1); + $shape = $this->layer->getfeature($shp_index,-1); + } + foreach ($items as $item) + { $v = trim($shape->values[$item]); $v = $this->converte($v); $valitem[] = $v; @@ -341,16 +356,22 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona for ($i = $inicio; $i < $res_count; ++$i) { $valitem = array(); + if($this->v == 6){ + $shape = $this->layer->getShape($this->layer->getResult($i)); + $indx = $shape->index; + } + else{ + $result = $this->layer->getResult($i); + $indx = $result->shapeindex; + $shape = $this->layer->getfeature($indx,-1); + } foreach ($items as $item) { - $result = $this->layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $this->layer->getfeature($shp_index,-1); $valori = trim($shape->values[$item]); $valori = $this->converte($valori); $valitem[] = array("item"=>$item,"valor"=>$valori); } - $registros[] = array("indice"=>$shp_index,"valores"=>$valitem,"status"=>$chk); + $registros[] = array("indice"=>$indx,"valores"=>$valitem,"status"=>$chk); } $resultadoFinal[] = array("registros"=>$registros); } @@ -378,11 +399,17 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona for ($i = $inicio; $i < $res_count; ++$i) { $valitem = array(); - foreach ($items as $item) - { + if($this->v == 6){ + $shape = $this->layer->getShape($this->layer->getResult($i)); + $indx = $shape->index; + } + else{ $result = $this->layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $this->layer->getfeature($shp_index,-1); + $indx = $result->shapeindex; + $shape = $this->layer->getfeature($indx,-1); + } + foreach ($items as $item) + { $valori = ""; if(@$shape->values[$item]) { @@ -392,9 +419,9 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona $valitem[] = array("item"=>$item,"valor"=>$valori); } //if (in_array($shp_index,$shp_atual)) - if(isset($shp_atual[$shp_index])) + if(isset($shp_atual[$indx])) {$chk = "CHECKED";} - $registros[] = array("indice"=>$shp_index,"valores"=>$valitem,"status"=>$chk); + $registros[] = array("indice"=>$indx,"valores"=>$valitem,"status"=>$chk); $chk = ""; } $this->layer->close(); @@ -533,9 +560,13 @@ Include: //pega os valores for ($i = 0; $i < $res_count; ++$i) { - $result = $this->layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $this->layer->getfeature($shp_index,-1); + if($this->v == 6) + {$shape = $this->layer->getShape($this->layer->getResult($i));} + else{ + $result = $this->layer->getResult($i); + $shp_index = $result->shapeindex; + $shape = $this->layer->getfeature($shp_index,-1); + } $v = $shape->values[$item]; $valores[] = $v; } @@ -1063,9 +1094,8 @@ $listaDeTemas - (opcional) Lista com os códigos dos temas que serão identificado for ($i = 0; $i < $res_count; ++$i) { $valori = array(); - $result = $layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $layer->getfeature($shp_index,-1); + $shape = $layer->getShape($layer->getResult($i)); + if ($tiporetorno == "shape") { $layer->close(); @@ -1322,9 +1352,13 @@ $listaDeTemas - (opcional) Lista com os códigos dos temas que serão identificado for ($i = 0; $i < $res_count; ++$i) { $valori = array(); - $result = $layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $layer->getfeature($shp_index,-1); + if($this->v == 6) + {$shape = $layer->getShape($layer->getResult($i));} + else{ + $result = $layer->getResult($i); + $shp_index = $result->shapeindex; + $shape = $layer->getfeature($shp_index,-1); + } $conta = 0; //var_dump($itens);exit; if($tiporetorno == "shape" || $tiporetorno == "googlerelevo"){ diff --git a/classesphp/classe_legenda.php b/classesphp/classe_legenda.php index 55d0af2..5992e97 100644 --- a/classesphp/classe_legenda.php +++ b/classesphp/classe_legenda.php @@ -513,20 +513,21 @@ String no formato HTML com as imagens dos símbolos */ function listaSimbolos($tipo,$dir_tmp,$imgdir,$onclick,$tamanho=8,$width=1) { + $versao = versao(); + $versao = $versao["principal"]; //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 == 2){$t="simpolv".$versao.".map";} + if ($tipo == 0){$t="simptv".$versao.".map";} if ($tipo == 1){ - $t="simlin.map"; + $t="simlinv".$versao.".map"; $tamanho = $tamanho / 4; } if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) @@ -534,19 +535,22 @@ String no formato HTML com as imagens dos símbolos else {$mapatemp = ms_newMapObj($this->localaplicacao."/aplicmap/".$t);} $ins = ""; - $ns = $mapatemp->getnumsymbols(); + $l = $mapatemp->getlayer(0); - $novoss = dirname($this->mapa->symbolsetfilename)."/".basename($mapatemp->symbolsetfilename); + $novoss = dirname($this->mapa->symbolsetfilename)."\\".basename($mapatemp->symbolsetfilename); $this->mapa->setsymbolset($novoss); + $ns = $this->mapa->getnumsymbols(); for ($i=0;$i < $ns;++$i) { $oSymbol = $this->mapa->getSymbolObjectById($i); $nomes = $oSymbol->name; + if($nomes == "") + {$nomes = $i;} $adiciona = ms_newLayerObj($this->mapa, $l); $nomel = $l->name; $tematemp= $this->mapa->getlayerbyname($nomel); $c = $tematemp->getClass(0); - $e = $c->getstyle(0); + $e = $c->getstyle(0); $e->set("symbolname",$nomes); $e->set("size",$tamanho); $e->set("width",$width); diff --git a/classesphp/classe_mapa.php b/classesphp/classe_mapa.php index e1464fa..d2a6c45 100644 --- a/classesphp/classe_mapa.php +++ b/classesphp/classe_mapa.php @@ -59,7 +59,12 @@ class Mapa Nome do arquivo de seleção (.qy) */ public $qyfile; + /* + Variavel: $v + Versão atual do Mapserver (primeiro dígito) + */ + public $v; /* Function: __construct @@ -77,6 +82,8 @@ $map_file - Endereço do mapfile no servidor. include_once($locaplic."/funcoes_gerais.php"); else include_once("funcoes_gerais.php"); + $this->v = versao(); + $this->v = $this->v["principal"]; $this->qyfile = str_replace(".map",".qy",$map_file); $this->locaplic = $locaplic; if(!file_exists($map_file)) @@ -1677,7 +1684,10 @@ $arq - Nome do shape file. if (file_exists($arq)) { $s = ms_newShapefileObj($arq,-1); - $shape = $s->getShape(0); + if($this->v == 6) + {$shape = $s->getshape(new resultObj(0));} + else + {$shape = $s->getshape(0);} $t = $shape->type; $tipo = MS_LAYER_POLYGON; if ($t == 0) diff --git a/classesphp/classe_selecao.php b/classesphp/classe_selecao.php index 0d664c4..aea3d5d 100644 --- a/classesphp/classe_selecao.php +++ b/classesphp/classe_selecao.php @@ -73,7 +73,13 @@ class Selecao Objeto projection original do mapa. Obtido apenas na interface Googlemaps */ - public $projO; + public $projO; + /* + Variavel: $v + + Versão atual do Mapserver (primeiro dígito) + */ + public $v; /* Function: __construct @@ -92,6 +98,12 @@ $ext - extensão geográfica do mapa function __construct($map_file,$tema="",$ext="") { + if(file_exists($locaplic."/funcoes_gerais.php")) + include_once($locaplic."/funcoes_gerais.php"); + else + include_once("funcoes_gerais.php"); + $this->v = versao(); + $this->v = $this->v["principal"]; $this->qyfile = str_replace(".map",".qy",$map_file); if($tema != "") {$this->qyfileTema = dirname($map_file)."/".$tema.".php";} @@ -271,9 +283,13 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa|novo $res_count = $layero->getNumresults(); for ($i = 0; $i < $res_count; ++$i) { - $result = $layero->getResult($i); - $s = $result->shapeindex; - $sh = $layero->getfeature($s,-1); + if($this->v == 6) + {$sh = $layero->getShape($layero->getResult($i));} + else{ + $result = $layero->getResult($i); + $s = $result->shapeindex; + $sh = $layero->getfeature($s,-1); + } $tiposh = $sh->type; if ($tiposh == 2) {$ident = @$this->layer->querybyshape($sh);} @@ -326,9 +342,11 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa|novo $conta = $layero->getNumresults(); for ($k = 0; $k < $conta; $k++) { - if (@$layero->getfeature($k,-1)) - { - $s = $layero->getfeature($k,-1); + if($this->v == 6) + {$s = @$layero->getShape($layero->getResult($k));} + else + {$s = @$layero->getfeature($k,-1);} + if($s){ if ($s->type == 2) { $this->layer->querybyshape($s); diff --git a/classesphp/classe_shp.php b/classesphp/classe_shp.php index a867028..fa86505 100644 --- a/classesphp/classe_shp.php +++ b/classesphp/classe_shp.php @@ -66,6 +66,12 @@ class SHP Indica se a biblioteca dbase está carregada */ protected $dbaseExiste; + /* + Variavel: $v + + Versão atual do Mapserver (primeiro dígito) + */ + public $v; /* function: __construct @@ -82,7 +88,13 @@ $ext - extensao geográfica que será aplicada ao mapa */ function __construct($map_file,$tema="",$locaplic="",$ext="") { - //error_reporting(E_ALL); + if (!function_exists('ms_newMapObj')) {return false;} + if(file_exists($locaplic."/funcoes_gerais.php")) + include_once($locaplic."/funcoes_gerais.php"); + else + include_once("funcoes_gerais.php"); + $this->v = versao(); + $this->v = $this->v["principal"]; $this->dbaseExiste = false; if(function_exists("dbase_create")) {$this->dbaseExiste = true;} @@ -383,9 +395,13 @@ array - xy $xy = array(); for ($i = 0; $i < $res_count; ++$i) { - $result = $this->layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $this->layer->getfeature($shp_index,-1); + if($this->v == 6) + {$shape = $this->layer->getShape($this->layer->getResult($i));} + else{ + $result = $this->layer->getResult($i); + $shp_index = $result->shapeindex; + $shape = $this->layer->getfeature($shp_index,-1); + } $nlinhas = $shape->numlines; for($j = 0;$j < $nlinhas; ++$j){ $lin = $shape->line($j); @@ -415,10 +431,13 @@ array("layerprj"=>$xylayer,"mapprj"=>$xymapa) $sopen = $this->layer->open(); if($sopen == MS_FAILURE){return "erro";} $xy = array(); - - $result = $this->layer->getResult($res_count - 1); - $shp_index = $result->shapeindex; - $shape = $this->layer->getfeature($shp_index,-1); + if($this->v == 6) + {$shape = $this->layer->getShape($this->layer->getshape(new resultObj($res_count - 1)));} + else{ + $result = $this->layer->getResult($res_count - 1); + $shp_index = $result->shapeindex; + $shape = $this->layer->getfeature($shp_index,-1); + } $lin = $shape->line(0); $pt = $lin->point(0); $this->layer->close(); diff --git a/classesphp/classe_temas.php b/classesphp/classe_temas.php index 26932d3..6e1527a 100644 --- a/classesphp/classe_temas.php +++ b/classesphp/classe_temas.php @@ -86,6 +86,12 @@ class Temas Nome do arquivo de seleção (.qy) */ public $qyfile; + /* + Variavel: $v + + Versão atual do Mapserver (primeiro dígito) + */ + public $v; /* function __construct @@ -109,6 +115,8 @@ $ext - (opcional) extensão geográfica que será aplicada ao mapa include_once($locaplic."/funcoes_gerais.php"); else include_once("funcoes_gerais.php"); + $this->v = versao(); + $this->v = $this->v["principal"]; $this->locaplic = $locaplic; if($map_file != "") { @@ -783,9 +791,13 @@ $nome - nome que será dado a geometria for ($i = 0; $i < $res_count; ++$i) { $valitem = array(); - $result = $this->layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $this->layer->getfeature($shp_index,-1); + if($this->v == 6) + {$shape = $this->layer->getShape($this->layer->getResult($i));} + else{ + $result = $this->layer->getResult($i); + $shp_index = $result->shapeindex; + $shape = $this->layer->getfeature($shp_index,-1); + } foreach ($items as $item) { $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 $res_count = $this->layer->getNumresults(); if($res_count > 0) { - $xmin = array(); - $xmax = array(); - $ymin = array(); - $ymax = array(); - for ($i = 0; $i < $res_count; ++$i) - { - $valitem = array(); - $result = $this->layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $this->layer->getfeature($shp_index,-1); - $bound = $shape->bounds; - $xmin[] = $bound->minx; - $xmax[] = $bound->maxx; - $ymin[] = $bound->miny; - $ymax[] = $bound->maxy; + $versao = versao(); + if($versao["principal"] == 6){ + $ret = $this->layer->getResultsBounds(); + } + else{ + $xmin = array(); + $xmax = array(); + $ymin = array(); + $ymax = array(); + for ($i = 0; $i < $res_count; ++$i) + { + $valitem = array(); + if($this->v == 6) + {$shape = $this->layer->getShape($this->layer->getResult($i));} + else{ + $result = $this->layer->getResult($i); + $shp_index = $result->shapeindex; + $shape = $this->layer->getfeature($shp_index,-1); + } + $bound = $shape->bounds; + $xmin[] = $bound->minx; + $xmax[] = $bound->maxx; + $ymin[] = $bound->miny; + $ymax[] = $bound->maxy; + } + $ret = ms_newRectObj(); + $ret->set("minx",min($xmin)); + $ret->set("miny",min($ymin)); + $ret->set("maxx",max($xmax)); + $ret->set("maxy",max($ymax)); } $this->layer->close(); - $ret = ms_newRectObj(); - $ret->set("minx",min($xmin)); - $ret->set("miny",min($ymin)); - $ret->set("maxx",max($xmax)); - $ret->set("maxy",max($ymax)); if (($prjTema != "") && ($prjMapa != $prjTema)) { $projInObj = ms_newprojectionobj($prjTema); diff --git a/classesphp/funcoes_gerais.php b/classesphp/funcoes_gerais.php index 5109b05..a956b69 100644 --- a/classesphp/funcoes_gerais.php +++ b/classesphp/funcoes_gerais.php @@ -1105,6 +1105,8 @@ function pegaValores($mapa,$layer,$item,$numerico=false,$ignorar="") { $layer->set("template","none.htm"); $layer->setfilter(""); + $versao = versao(); + $versao = $versao["principal"]; if (@$layer->queryByrect($mapa->extent) == MS_SUCCESS) { $sopen = $layer->open(); @@ -1113,9 +1115,13 @@ function pegaValores($mapa,$layer,$item,$numerico=false,$ignorar="") $valitem = array(); for ($i=0;$i<$res_count;++$i) { - $result = $layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $layer->getfeature($shp_index,-1); + if($versao == 6) + {$shape = $layer->getShape($layer->getResult($i));} + else{ + $result = $layer->getResult($i); + $shp_index = $result->shapeindex; + $shape = $layer->getfeature($shp_index,-1); + } $v = trim($shape->values[$item]); if ($numerico) { @@ -1173,7 +1179,8 @@ Retorno: */ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$chaves=false,$centroide=false) { - //error_reporting(E_ALL); + $versao = versao(); + $versao = $versao["principal"]; $prjMapa = $mapa->getProjection(); $prjTema = $layer->getProjection(); $layer->set("template","none.htm"); @@ -1204,12 +1211,18 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$ch for ($i=0;$i<$res_count;++$i) { - $result = $layer->getResult($i); - $shp_index = $result->shapeindex; + if($versao == 6){ + $shape = $layer->getShape($layer->getResult($i)); + $shp_index = $shape->index; + } + else{ + $result = $layer->getResult($i); + $shp_index = $result->shapeindex; + $shape = $layer->getfeature($shp_index,-1); + } if (($selecionados == "sim") && (array_search($shp_index,$indicesel) === FALSE)) {continue;} $considera = "sim"; - $shape = $layer->getfeature($shp_index,-1); //verifica se no registro deve ser considerado if ($exclui != "nulo") { @@ -1804,6 +1817,8 @@ Retorno: */ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) { + $versao = versao(); + $versao = $versao["principal"]; //para manipular dbf if(file_exists($locaplic."/pacotes/phpxbase/api_conversion.php")) include_once($locaplic."/pacotes/phpxbase/api_conversion.php"); @@ -1842,10 +1857,14 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) dbase_add_record($db,$reg); dbase_close($db); } - $s = $layer->getfeature(0,-1); - $result = $layer->getResult(0); - $shpi = $result->shapeindex; - $shape = $layer->getfeature($shpi,-1); + if($versao == 6) + {$shape = $layer->getshape(new resultObj(0));} + else{ + $s = $layer->getfeature(0,-1); + $result = $layer->getResult(0); + $shpi = $result->shapeindex; + $shape = $layer->getfeature($shpi,-1); + } $novoshpf = ms_newShapefileObj($nomeshp.".shp", -2); $novoshpf->addShape($shape); $novoshpf->free(); @@ -1886,9 +1905,13 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) if($sopen == MS_FAILURE){return "erro";} for ($i = 0; $i < $res_count; ++$i) { - $result = $layer->getResult($i); - $shp_index = $result->shapeindex; - $shape = $layer->getfeature($shp_index,-1); + if($versao == 6) + {$shape = $layer->getShape($layer->getResult($i));} + else{ + $result = $layer->getResult($i); + $shp_index = $result->shapeindex; + $shape = $layer->getfeature($shp_index,-1); + } foreach ($items as $ni) { $vreg = $shape->values[$ni]; diff --git a/classesphp/mapa_googlemaps.php b/classesphp/mapa_googlemaps.php index 1ab60bf..48c9efe 100644 --- a/classesphp/mapa_googlemaps.php +++ b/classesphp/mapa_googlemaps.php @@ -263,10 +263,12 @@ if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") } else{ if($cache == true) - {salvaCacheImagem($_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);} + {$nomer = salvaCacheImagem($_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);} + else{ + $nomer = ($img->imagepath)."imgtemp".nomeRandomico().".png"; + $img->saveImage($nomer); + } ob_clean(); - $nomer = ($img->imagepath)."imgtemp".nomeRandomico().".png"; - $img->saveImage($nomer); $img = imagecreatefrompng($nomer); imagealphablending($img, false); imagesavealpha($img, true); @@ -286,6 +288,7 @@ function salvaCacheImagem($bbox,$layer,$map,$w,$h){ $nome = $nomedir."/".$w.$h.$bbox.".png"; if(!file_exists($nome)) {$img->saveImage($nome);} + return $nome; } function carregaCacheImagem($bbox,$layer,$map,$w,$h){ if($layer == "copyright" || $layer == "") diff --git a/classesphp/mapa_inicia.php b/classesphp/mapa_inicia.php index be9061d..2b1b585 100644 --- a/classesphp/mapa_inicia.php +++ b/classesphp/mapa_inicia.php @@ -223,16 +223,18 @@ function iniciaMapa() $l->set("status",MS_DELETE); } $of = $mf->outputformat; + $of->set("driver","GD/PNG"); + /* $versao = versao(); if($versao["principal"] == 6) {$of->set("driver","GD/PNG");} else {$of->set("driver","AGG/PNG");} - - + */ $temp = $mf->scalebar; $temp->set("status",MS_OFF); $mf->save($nomefundo); + // $temp = $m->mapa->scalebar; $temp->set("status",MS_OFF); $of = $m->mapa->outputformat; diff --git a/classesphp/mapa_openlayers.php b/classesphp/mapa_openlayers.php index 6ce8bca..b1174ab 100644 --- a/classesphp/mapa_openlayers.php +++ b/classesphp/mapa_openlayers.php @@ -255,15 +255,16 @@ if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") } else{ if($cache == true) - {salvaCacheImagem($_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);} + {$nomer = salvaCacheImagem($_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);} + else{ + $nomer = ($img->imagepath)."imgtemp".nomeRandomico().".png"; + $img->saveImage($nomer); + } ob_clean(); - $nomer = ($img->imagepath)."imgtemp".nomeRandomico().".png"; - $img->saveImage($nomer); $img = imagecreatefrompng($nomer); imagealphablending($img, false); imagesavealpha($img, true); ob_clean(); - echo header("Content-type: image/png \n\n"); imagepng($img); imagedestroy($img); @@ -284,6 +285,7 @@ function salvaCacheImagem($bbox,$layer,$map,$w,$h){ $img->saveImage($nome); chmod($nome,0777); } + return $nome; } function carregaCacheImagem($bbox,$layer,$map,$w,$h){ if($layer == "copyright" || $layer == "") -- libgit2 0.21.2