From 4f6049e612be03f8b0a30e36ed6d31ab55f62569 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Tue, 25 Jun 2013 15:26:00 +0000 Subject: [PATCH] Alterações para permitir o uso de simbolos inline nos mapfiles --- admin/admin.db | Bin 204800 -> 0 bytes classesphp/classe_mapa.php | 1 + classesphp/funcoes_gerais.php | 39 +++++++++++++++++++++++++++++++++++++++ geraminiatura.php | 3 ++- imagens/google/condominium.png | Bin 0 -> 677 bytes imagens/google/condominium1.png | Bin 0 -> 835 bytes ms_criamapa.php | 1 + ogc.php | 5 +++-- temas/_llocali.map | 19 ++++++++++++------- testamapfile.php | 837 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 10 files changed, 465 insertions(+), 440 deletions(-) create mode 100644 imagens/google/condominium.png create mode 100644 imagens/google/condominium1.png diff --git a/admin/admin.db b/admin/admin.db index 0e31e0c..3dc04dd 100644 Binary files a/admin/admin.db and b/admin/admin.db differ diff --git a/classesphp/classe_mapa.php b/classesphp/classe_mapa.php index ad6b2f2..d2fa168 100644 --- a/classesphp/classe_mapa.php +++ b/classesphp/classe_mapa.php @@ -1100,6 +1100,7 @@ $random - indica se os nomes dos novos layers serão modificados ou nao $nlayer->setmetadata("wms_sld_body",str_replace('"',"'",$sld)); $nlayer->set("type",$tipotemp); } + cloneInlineSymbol($nlayer,$nmap,$this->mapa); ms_newLayerObj($this->mapa, $nlayer); $l = $this->mapa->getlayerbyname($nlayer->name); //reposiciona o layer se for o caso diff --git a/classesphp/funcoes_gerais.php b/classesphp/funcoes_gerais.php index 7842bfe..c8d883a 100644 --- a/classesphp/funcoes_gerais.php +++ b/classesphp/funcoes_gerais.php @@ -2635,4 +2635,43 @@ function listaGruposUsrLogin(){ session_start(); return $res; } +/* +Function: cloneInlineSymbol + +Importa os simbolos inline de um layer de um mapfile para outro mapfile + +@fixme +No caso de imagens, o nome do simbolo deve ser o mesmo do caminho da imagem (bug do mapserver) + +Parameters: + +layern - objeto layer que contem o simbolo original + +nmapa - objeto map que contem o layer layern + +mapa - objeto mapa destino do simbolo clonado +*/ +function cloneInlineSymbol($layern,$nmapa,$mapa){ + $versao = versao(); + if($versao["principal"] > 5){ + $numclasses = $layern->numclasses; + for($ci=0;$ci < $numclasses;$ci++){ + $classe = $layern->getclass($ci); + $numestilos = $classe->numstyles; + for($ei=0;$ei < $numestilos;$ei++){ + $estilo = $classe->getstyle($ei); + if($estilo->symbolname != ""){ + $nomesimbolo = $estilo->symbolname; + $simbolo = new symbolObj($nmapa, $nomesimbolo); + $ipath = $simbolo->imagepath; + if($simbolo->inmapfile == MS_TRUE){ + $simbolon = new symbolObj($mapa, $nomesimbolo); + $simbolon->set("inmapfile",MS_TRUE); + $simbolon->setImagePath($ipath); + } + } + } + } + } +} ?> diff --git a/geraminiatura.php b/geraminiatura.php index cc6dce9..64e39a1 100644 --- a/geraminiatura.php +++ b/geraminiatura.php @@ -213,6 +213,7 @@ function verificaMiniatura($map,$tipo,$admin=false) for ($i=0;$i < $numlayers;$i++){ $layern = $nmapa->getlayer($i); $layern->set("status",MS_DEFAULT); + cloneInlineSymbol($layern,$nmapa,$mapa); ms_newLayerObj($mapa, $layern); autoClasses($layern,$mapa,$locaplic); if ($layern->data == ""){ @@ -261,7 +262,7 @@ function verificaMiniatura($map,$tipo,$admin=false) $urlM = $weboM->imageurl."/".$map; } if ($tipo == "grande" || $tipo == "todos"){ - $mapa->setsize(300,300); + $mapa->setsize(300,300); $sca = $mapa->scalebar; $sca->set("status",MS_OFF); $objImagemG = @$mapa->draw(); diff --git a/imagens/google/condominium.png b/imagens/google/condominium.png new file mode 100644 index 0000000..246b892 Binary files /dev/null and b/imagens/google/condominium.png differ diff --git a/imagens/google/condominium1.png b/imagens/google/condominium1.png new file mode 100644 index 0000000..779592a Binary files /dev/null and b/imagens/google/condominium1.png differ diff --git a/ms_criamapa.php b/ms_criamapa.php index af3510f..10bc033 100644 --- a/ms_criamapa.php +++ b/ms_criamapa.php @@ -722,6 +722,7 @@ function incluiTemasIniciais(){ $layern->set("type",$tipotemp); $layern->set("status",$statustemp); } + cloneInlineSymbol($layern,$maptemp,$mapn); ms_newLayerObj($mapn, $layern); } } diff --git a/ogc.php b/ogc.php index b391f1b..1c5db58 100644 --- a/ogc.php +++ b/ogc.php @@ -1,6 +1,6 @@ setmetadata("wms_attribution_logourl_height","50"); $l->setmetadata("wms_attribution_logourl_width","50"); $l->setmetadata("wms_attribution_logourl_href",$mini); - } + } + cloneInlineSymbol($l,$nmap,$oMap); ms_newLayerObj($oMap, $l); } } diff --git a/temas/_llocali.map b/temas/_llocali.map index 6020204..edcdc88 100644 --- a/temas/_llocali.map +++ b/temas/_llocali.map @@ -3,9 +3,14 @@ MAP #SYMBOLSET "../symbols/vazio.sym" SYMBOLSET "../symbols/simbolosv6.sym" SYMBOL - NAME "teste" + NAME "/var/www/i3geo/imagens/google/condominium.png" TYPE pixmap - IMAGE "/var/www/i3geo/imagens/google/foto.png" + IMAGE "/var/www/i3geo/imagens/google/condominium.png" +END +SYMBOL + NAME "/var/www/i3geo/imagens/google/condominium1.png" + TYPE pixmap + IMAGE "/var/www/i3geo/imagens/google/condominium1.png" END LAYER CONNECTION "" @@ -58,8 +63,8 @@ END ANGLE 0 COLOR 250 193 4 OFFSET 0 0 - SIZE 4 - SYMBOL "ponto" + SIZE 20 + SYMBOL "/var/www/i3geo/imagens/google/condominium.png" END # STYLE END # CLASS CLASS @@ -69,8 +74,8 @@ END ANGLE 0 COLOR 62 9 41 OFFSET 0 0 - SIZE 6 - SYMBOL "teste" + SIZE 20 + SYMBOL "/var/www/i3geo/imagens/google/condominium1.png" END # STYLE END # CLASS CLASS @@ -81,7 +86,7 @@ END COLOR 112 203 244 OFFSET 0 0 SIZE 6 - SYMBOL "capital" + SYMBOL "vila" END # STYLE END # CLASS END # LAYER diff --git a/testamapfile.php b/testamapfile.php index 70a7950..a0e5d0e 100644 --- a/testamapfile.php +++ b/testamapfile.php @@ -1,444 +1,421 @@ -'; - echo ''; - echo ''; - echo ''; - - echo ''; - echo '
 
'; - echo '
'; - echo 'Nome do arquivo map existente no diretório i3geo/temas. Exemplo para uso manual da URL: testamapfile.php?map=biomashp (utilize "testamapfile.php?map=todos" na URL para testar todos de uma só vez)

'; - echo '
Mostra apenas a legenda? sim não
'; - $combo = "

"; -} -if (isset($map) && $map != "") -{ - if(!isset($solegenda)){$solegenda = "nao";} - if ($map == "todos") - { - $tipo = "todos"; - $conta = 0; - echo "
Número de mapas = ".(count($arqs["arquivos"]))." Faltam= ".(count($arqs["arquivos"])-$iniciar-10)."
"; - if (!isset($iniciar)){$iniciar = 0;} - foreach ($arqs["arquivos"] as $arq) - { - if (($conta >= $iniciar) && ($conta < $iniciar+10)){ - //arquivos php so sao validos se estiverem em i3geo/temas - verifica($arq,$solegenda); - } - $conta++; - } - echo "


Próximos mapas"; - } - else - {verifica($map,$solegenda);} -} -echo '
'; -echo ''; -echo ''; -function verifica($map,$solegenda){ - global $tipo,$locaplic,$postgis_mapa,$versao,$base,$dir_tmp; - $mapUrl = $map; - if ($tipo == "mini" && file_exists('temas/miniaturas/'.$map.".mini.png")){ - Header("Content-type: image/png"); - ImagePng(ImageCreateFromPNG('temas/miniaturas/'.$map.".mini.png")); - exit; - } - if ($tipo == "grande" && file_exists('temas/miniaturas/'.$map.".grande.png")){ - Header("Content-type: image/png"); - ImagePng(ImageCreateFromPNG('temas/miniaturas/'.$map.".grande.png")); - exit; - } - ms_ResetErrorList(); - $tema = ""; - if(file_exists($map)){ - $tema = $map; - } - else{ - $map = str_replace("\\","/",$map); - $map = basename($map); - if (file_exists('temas/'.$map)) - {$tema = 'temas/'.$map;} - if (file_exists('temas/'.$map.'.map')) - {$tema = 'temas/'.$map.".map";} - if (file_exists('temas/'.$map.'.php')) - {$tema = 'temas/'.$map.".php";} +'; + echo ''; + echo ''; + echo ''; + + echo ''; + echo '
 
'; + echo '
'; + echo 'Nome do arquivo map existente no diretório i3geo/temas. Exemplo para uso manual da URL: testamapfile.php?map=biomashp (utilize "testamapfile.php?map=todos" na URL para testar todos de uma só vez)

'; + echo '
Mostra apenas a legenda? sim não
'; + $combo = "

"; +} +if (isset($map) && $map != "") +{ + if(!isset($solegenda)){$solegenda = "nao";} + if ($map == "todos") + { + $tipo = "todos"; + $conta = 0; + echo "
Número de mapas = ".(count($arqs["arquivos"]))." Faltam= ".(count($arqs["arquivos"])-$iniciar-10)."
"; + if (!isset($iniciar)){$iniciar = 0;} + foreach ($arqs["arquivos"] as $arq) + { + if (($conta >= $iniciar) && ($conta < $iniciar+10)){ + //arquivos php so sao validos se estiverem em i3geo/temas + verifica($arq,$solegenda); + } + $conta++; + } + echo "


Próximos mapas"; + } + else + {verifica($map,$solegenda);} +} +echo '
'; +echo ''; +echo ''; +function verifica($map,$solegenda){ + global $tipo,$locaplic,$postgis_mapa,$versao,$base,$dir_tmp; + $mapUrl = $map; + if ($tipo == "mini" && file_exists('temas/miniaturas/'.$map.".mini.png")){ + Header("Content-type: image/png"); + ImagePng(ImageCreateFromPNG('temas/miniaturas/'.$map.".mini.png")); + exit; + } + if ($tipo == "grande" && file_exists('temas/miniaturas/'.$map.".grande.png")){ + Header("Content-type: image/png"); + ImagePng(ImageCreateFromPNG('temas/miniaturas/'.$map.".grande.png")); + exit; + } + ms_ResetErrorList(); + $tema = ""; + if(file_exists($map)){ + $tema = $map; + } + else{ + $map = str_replace("\\","/",$map); + $map = basename($map); + if (file_exists('temas/'.$map)) + {$tema = 'temas/'.$map;} + if (file_exists('temas/'.$map.'.map')) + {$tema = 'temas/'.$map.".map";} + if (file_exists('temas/'.$map.'.php')) + {$tema = 'temas/'.$map.".php";} if (file_exists('temas/'.$map.'.gvp')) - {$tema = 'temas/'.$map.".gvp";} - } - if(!file_exists($tema)){ - $tema = $locaplic."/".$tema; - } - if(($tipo == "") || ($tipo == "todos")){ - echo "


Testando: $tema
";
-	}
-	if(!file_exists($tema)){
-		echo "Arquivo ".$map." não encontrado.";
-		exit;
-	}
-	if ($tema != ""){
-		if($base == "" or !isset($base)){
-			$base = "";
-			if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')){
-				$base = $locaplic."/aplicmap/geral1windowsv".$versao.".map";
-			}
-			else{
-				if($base == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv'.$versao.'.map')){
-					$base = "/var/www/i3geo/aplicmap/geral1debianv".$versao.".map";
-				}
-				if($base == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){
-					$base = "/var/www/html/i3geo/aplicmap/geral1fedorav".$versao.".map";
-				}
-				if($base == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){
-					$base = "/opt/www/html/i3geo/aplicmap/geral1v".$versao.".map";
-				}
-				if($base == ""){
-					$base = $locaplic."/aplicmap/geral1v".$versao.".map";
-				}
-			}
-		}
-		else{
-			if(!file_exists($base)){
-				$base = $locaplic."/aplicmap/".$base;
-			}
-		}
-		//echo $base;exit;
-		$mapa = ms_newMapObj($base);
-		error_reporting(0);
-		$numlayers = $mapa->numlayers;
-		for ($i=0;$i < $numlayers;$i++){
-			$layern = $mapa->getlayer($i);
-			if (!empty($postgis_mapa)){
-				if ($layern->connectiontype == MS_POSTGIS){
-					$lcon = $layern->connection;
-					if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){
-						if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade
-						{$layern->set("connection",$postgis_mapa);}
-						else{
-							$layern->set("connection",$postgis_mapa[$lcon]);
-						}
-					}
-				}
-			}
-		}
-		if(!stristr($tema, '.php') === FALSE){
-			echo "
Arquivo $tema é um programa PHP. O teste pode não funcionar.
"; - include_once($locaplic."/".$tema); - // - //$pegarext deve guardar o nome da camada para ser usado mais abaixo - // - $pegarext = str_replace(".php","",$tema); - $pegarext = str_replace("temas/","",$pegarext); - eval($pegarext."(\$mapa);"); - } - if(!stristr($tema, '.map') === FALSE){ - if(file_exists($mapUrl)){ - if(@ms_newMapObj($mapUrl)){ - $nmapa = ms_newMapObj($mapUrl); - } - else{ - echo "Erro no arquivo $mapUrl
"; - $error = ms_GetErrorObj(); - while($error && $error->code != MS_NOERR){ - printf("
Error in %s: %s
\n", $error->routine, $error->message); - $error = $error->next(); - } - return; - } - } - else{ - if(@ms_newMapObj($locaplic."/".$tema)){ - if(!function_exists("validaAcessoTemas")){ - include($locaplic."/classesphp/funcoes_gerais.php"); - } - if(validaAcessoTemas($locaplic."/".$tema,false) == false){ - $nmapa = ms_newMapObj($locaplic."/".$tema); - } - else{ - echo "tema restrito
"; - exit; - } - } - else{ - echo "erro no arquivo $map
"; - echo "Obs.: em alguns testes o mapfile pode falhar se o endereço dos arquivos de símbolos estiverem
definidos de forma relativa ao invés de absoluta. Nesses casos, ao abrir o i3Geo,
o mapfile poderá funcionar.
"; - $error = ms_GetErrorObj(); - while($error && $error->code != MS_NOERR){ - printf("
Error in %s: %s
\n", $error->routine, $error->message); - $error = $error->next(); - } - return; - } - } - $numlayers = $nmapa->numlayers; - $dados = ""; - $simbolos = array(); - for ($i=0;$i < $numlayers;$i++){ - $layern = $nmapa->getlayer($i); - $layern->set("status",MS_DEFAULT); - if (!empty($postgis_mapa)){ - if ($layern->connectiontype == MS_POSTGIS){ - $lcon = $layern->connection; - error_reporting(0); - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ - if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade - {$layern->set("connection",$postgis_mapa);} - else - {$layern->set("connection",$postgis_mapa[$lcon]);} - } - } - } - autoClasses($layern,$nmapa); - error_reporting(0); - if($layern->classitem != "" && $layern->connectiontype == 7 && $layern->numclasses > 0 && $layern->getmetadata("wms_sld_body") == ""){ - $tipotemp = $layern->type; - $tiporep = $layern->getmetadata("tipooriginal"); - $layern->set("type",MS_LAYER_POLYGON); - if ($tiporep == "linear"){ - $layern->set("type",MS_LAYER_LINE); - } - if ($tiporep == "pontual"){ - $layern->set("type",MS_LAYER_POINT); - } - $sld = $layern->generateSLD(); - if($sld != ""){ - $layern->setmetadata("wms_sld_body",str_replace('"',"'",$sld)); - } - $layern->set("type",$tipotemp); - } - ms_newLayerObj($mapa, $layern); - - //pega simbolos locais e aplica no novo mapa - $numclasses = $layern->numclasses; - for($ci=0;$ci < $numclasses;$ci++){ - $classe = $layern->getclass($ci); - $numestilos = $classe->numstyles; - for($ei=0;$ei < $numestilos;$ei++){ - $estilo = $classe->getstyle($ei); - if($estilo->symbolname != ""){ - $nomesimbolo = $estilo->symbolname; - $simbolo = new symbolObj($nmapa, $nomesimbolo); - $ipath = $simbolo->imagepath; - if(ms_newSymbolObj($nmapa, $nomesimbolo) != ms_newSymbolObj($mapa, $nomesimbolo)+1){ - $simbolon = new symbolObj($mapa, $nomesimbolo); - $simbolon->set("inmapfile",MS_TRUE); - $simbolon->setImagePath($ipath); - } - //algumas versoes do mapserver nao funciona - if($simbolon->imagePath != $ipath){ - $layern->set("status",MS_DELETE); - } + {$tema = 'temas/'.$map.".gvp";} + } + if(!file_exists($tema)){ + $tema = $locaplic."/".$tema; + } + if(($tipo == "") || ($tipo == "todos")){ + echo "


Testando: $tema
";
+	}
+	if(!file_exists($tema)){
+		echo "Arquivo ".$map." não encontrado.";
+		exit;
+	}
+	if ($tema != ""){
+		if($base == "" or !isset($base)){
+			$base = "";
+			if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')){
+				$base = $locaplic."/aplicmap/geral1windowsv".$versao.".map";
+			}
+			else{
+				if($base == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv'.$versao.'.map')){
+					$base = "/var/www/i3geo/aplicmap/geral1debianv".$versao.".map";
+				}
+				if($base == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){
+					$base = "/var/www/html/i3geo/aplicmap/geral1fedorav".$versao.".map";
+				}
+				if($base == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){
+					$base = "/opt/www/html/i3geo/aplicmap/geral1v".$versao.".map";
+				}
+				if($base == ""){
+					$base = $locaplic."/aplicmap/geral1v".$versao.".map";
+				}
+			}
+		}
+		else{
+			if(!file_exists($base)){
+				$base = $locaplic."/aplicmap/".$base;
+			}
+		}
+		//echo $base;exit;
+		$mapa = ms_newMapObj($base);
+		error_reporting(0);
+		$numlayers = $mapa->numlayers;
+		for ($i=0;$i < $numlayers;$i++){
+			$layern = $mapa->getlayer($i);
+			if (!empty($postgis_mapa)){
+				if ($layern->connectiontype == MS_POSTGIS){
+					$lcon = $layern->connection;
+					if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){
+						if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade
+						{$layern->set("connection",$postgis_mapa);}
+						else{
+							$layern->set("connection",$postgis_mapa[$lcon]);
+						}
+					}
+				}
+			}
+		}
+		if(!stristr($tema, '.php') === FALSE){
+			echo "
Arquivo $tema é um programa PHP. O teste pode não funcionar.
"; + include_once($locaplic."/".$tema); + // + //$pegarext deve guardar o nome da camada para ser usado mais abaixo + // + $pegarext = str_replace(".php","",$tema); + $pegarext = str_replace("temas/","",$pegarext); + eval($pegarext."(\$mapa);"); + } + if(!stristr($tema, '.map') === FALSE){ + if(file_exists($mapUrl)){ + if(@ms_newMapObj($mapUrl)){ + $nmapa = ms_newMapObj($mapUrl); + } + else{ + echo "Erro no arquivo $mapUrl
"; + $error = ms_GetErrorObj(); + while($error && $error->code != MS_NOERR){ + printf("
Error in %s: %s
\n", $error->routine, $error->message); + $error = $error->next(); + } + return; + } + } + else{ + if(@ms_newMapObj($locaplic."/".$tema)){ + if(!function_exists("validaAcessoTemas")){ + include($locaplic."/classesphp/funcoes_gerais.php"); + } + if(validaAcessoTemas($locaplic."/".$tema,false) == false){ + $nmapa = ms_newMapObj($locaplic."/".$tema); + } + else{ + echo "tema restrito
"; + exit; + } + } + else{ + echo "erro no arquivo $map
"; + echo "Obs.: em alguns testes o mapfile pode falhar se o endereço dos arquivos de símbolos estiverem
definidos de forma relativa ao invés de absoluta. Nesses casos, ao abrir o i3Geo,
o mapfile poderá funcionar.
"; + $error = ms_GetErrorObj(); + while($error && $error->code != MS_NOERR){ + printf("
Error in %s: %s
\n", $error->routine, $error->message); + $error = $error->next(); + } + return; + } + } + $numlayers = $nmapa->numlayers; + $dados = ""; + $simbolos = array(); + for ($i=0;$i < $numlayers;$i++){ + $layern = $nmapa->getlayer($i); + $layern->set("status",MS_DEFAULT); + if (!empty($postgis_mapa)){ + if ($layern->connectiontype == MS_POSTGIS){ + $lcon = $layern->connection; + error_reporting(0); + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ + if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade + {$layern->set("connection",$postgis_mapa);} + else + {$layern->set("connection",$postgis_mapa[$lcon]);} } } - } - - if ($layern->data == ""){ - $dados = $layern->connection; - } - else{ - $dados = $layern->data; - } - $pegarext = $layern->name; - } - zoomTema($pegarext,$mapa); - } - if(!stristr($tema, '.gvp') === FALSE){ + } + autoClasses($layern,$nmapa); + error_reporting(0); + if($layern->classitem != "" && $layern->connectiontype == 7 && $layern->numclasses > 0 && $layern->getmetadata("wms_sld_body") == ""){ + $tipotemp = $layern->type; + $tiporep = $layern->getmetadata("tipooriginal"); + $layern->set("type",MS_LAYER_POLYGON); + if ($tiporep == "linear"){ + $layern->set("type",MS_LAYER_LINE); + } + if ($tiporep == "pontual"){ + $layern->set("type",MS_LAYER_POINT); + } + $sld = $layern->generateSLD(); + if($sld != ""){ + $layern->setmetadata("wms_sld_body",str_replace('"',"'",$sld)); + } + $layern->set("type",$tipotemp); + } + //pega simbolos locais e aplica no novo mapa + cloneInlineSymbol($layern,$nmapa,$mapa); + ms_newLayerObj($mapa, $layern); + if ($layern->data == ""){ + $dados = $layern->connection; + } + else{ + $dados = $layern->data; + } + $pegarext = $layern->name; + } + zoomTema($pegarext,$mapa); + } + if(!stristr($tema, '.gvp') === FALSE){ if(file_exists($mapUrl)){ $gvsiggvp = $mapUrl; } else{ $gvsiggvp = $locaplic."/".$tema; - } + } include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"); - $gm = new gvsig2mapfile($gvsiggvp); + $gm = new gvsig2mapfile($gvsiggvp); $gvsigview = $gm->getViewsNames(); - foreach($gvsigview as $v){ + foreach($gvsigview as $v){ $dataView = $gm->getViewData($v); - $mapa = $gm->addLayers($mapa,$v,$dataView["layerNames"]); - } + $mapa = $gm->addLayers($mapa,$v,$dataView["layerNames"]); + } $next = $dataView["extent"]; $ext = $mapa->extent; $ext->setextent($next[0],$next[1],$next[2],$next[3]); - - } - if ($tipo == "mini"){ - $mapa->setsize(50,50); - $sca = $mapa->scalebar; - $sca->set("status",MS_OFF); - } - if ($tipo == "grande"){ - $mapa->setsize(300,300); - $sca = $mapa->scalebar; - $sca->set("status",MS_OFF); - } - if($tipo == "todos"){ - $mapa->setsize(150,150); - $sca = $mapa->scalebar; - $sca->set("status",MS_OFF); - } - $destino = $dir_tmp."/".nomeRandomico().".map"; - echo $destino;exit; - $mapa->save($destino); - - $mapa = ms_newMapObj($destino); - $objImagem = @$mapa->draw(); - $objImagemLegenda = @$mapa->drawLegend(); - if (!$objImagem){ - echo "Problemas ao gerar o mapa
"; - $error = ""; - $error = ms_GetErrorObj(); - while($error && $error->code != MS_NOERR){ - echo "
Error in %s: %s
", $error->routine, $error->message; - $error = $error->next(); - } - return; - } - if($objImagem->imagepath == "") - {echo "Erro IMAGEPATH vazio";} - $nomec = ($objImagem->imagepath).nomeRandomico()."teste.png"; - $objImagem->saveImage($nomec); - $nomer = ($objImagem->imageurl).basename($nomec); - - $nomel = ($objImagemLegenda->imagepath).nomeRandomico()."testel.png"; - $objImagemLegenda->saveImage($nomel); - $nomerl = ($objImagemLegenda->imageurl).basename($nomel); - if(($tipo == "") || ($tipo == "todos")){ - if($solegenda == "nao") - {echo "
";} - echo ""; - if($tipo == "todos"){ - echo "
".$dados."
"; - } - if($map != "todos"){ - echo "
Erros:
"; - $error = ""; - $error = ms_GetErrorObj(); - while($error && $error->code != MS_NOERR){ - echo "
Error in %s: %s
", $error->routine, $error->message; - $error = $error->next(); - } - } - - } - else{ - Header("Content-type: image/png"); - ImagePng(ImageCreateFromPNG($nomec)); - } - //$objImagem->free(); - } -} -function zoomTema($nomelayer,&$mapa){ - $layer = $mapa->getlayerbyname($nomelayer); - if($layer->data == "" && $layer->connection == "") - {return;} - $prjMapa = $mapa->getProjection(); - $prjTema = $layer->getProjection(); - $extatual = $mapa->extent; - $ret = $layer->getmetadata("extensao"); - if($layer->type > 2 && $ret == "") - {return;} - $ct = $layer->connectiontype; - if(($ret == "") && ($ct != 1)) - {return;} - if ($ret == ""){ - $ret = $layer->getextent(); - //reprojeta o retangulo - if (($prjTema != "") && ($prjMapa != $prjTema)){ - $projInObj = ms_newprojectionobj($prjTema); - $projOutObj = ms_newprojectionobj($prjMapa); - $ret->project($projInObj, $projOutObj); - } - $extatual->setextent($ret->minx,$ret->miny,$ret->maxx,$ret->maxy); - } - else{ - $ret = explode(" ",$ret); - $extatual->setextent($ret[0],$ret[1],$ret[2],$ret[3]); - } -} -?> + + } + if ($tipo == "mini"){ + $mapa->setsize(50,50); + $sca = $mapa->scalebar; + $sca->set("status",MS_OFF); + } + if ($tipo == "grande"){ + $mapa->setsize(300,300); + $sca = $mapa->scalebar; + $sca->set("status",MS_OFF); + } + if($tipo == "todos"){ + $mapa->setsize(150,150); + $sca = $mapa->scalebar; + $sca->set("status",MS_OFF); + } + $destino = $dir_tmp."/".nomeRandomico().".map"; + + $mapa->save($destino); + //echo $destino;exit; + $mapa = ms_newMapObj($destino); + $objImagem = @$mapa->draw(); + $objImagemLegenda = @$mapa->drawLegend(); + if (!$objImagem){ + echo "Problemas ao gerar o mapa
"; + $error = ""; + $error = ms_GetErrorObj(); + while($error && $error->code != MS_NOERR){ + echo "
Error in %s: %s
", $error->routine, $error->message; + $error = $error->next(); + } + return; + } + if($objImagem->imagepath == "") + {echo "Erro IMAGEPATH vazio";} + $nomec = ($objImagem->imagepath).nomeRandomico()."teste.png"; + $objImagem->saveImage($nomec); + $nomer = ($objImagem->imageurl).basename($nomec); + + $nomel = ($objImagemLegenda->imagepath).nomeRandomico()."testel.png"; + $objImagemLegenda->saveImage($nomel); + $nomerl = ($objImagemLegenda->imageurl).basename($nomel); + if(($tipo == "") || ($tipo == "todos")){ + if($solegenda == "nao") + {echo "
";} + echo ""; + if($tipo == "todos"){ + echo "
".$dados."
"; + } + if($map != "todos"){ + echo "
Erros:
"; + $error = ""; + $error = ms_GetErrorObj(); + while($error && $error->code != MS_NOERR){ + echo "
Error in %s: %s
", $error->routine, $error->message; + $error = $error->next(); + } + } + + } + else{ + Header("Content-type: image/png"); + ImagePng(ImageCreateFromPNG($nomec)); + } + //$objImagem->free(); + } +} +function zoomTema($nomelayer,&$mapa){ + $layer = $mapa->getlayerbyname($nomelayer); + if($layer->data == "" && $layer->connection == "") + {return;} + $prjMapa = $mapa->getProjection(); + $prjTema = $layer->getProjection(); + $extatual = $mapa->extent; + $ret = $layer->getmetadata("extensao"); + if($layer->type > 2 && $ret == "") + {return;} + $ct = $layer->connectiontype; + if(($ret == "") && ($ct != 1)) + {return;} + if ($ret == ""){ + $ret = $layer->getextent(); + //reprojeta o retangulo + if (($prjTema != "") && ($prjMapa != $prjTema)){ + $projInObj = ms_newprojectionobj($prjTema); + $projOutObj = ms_newprojectionobj($prjMapa); + $ret->project($projInObj, $projOutObj); + } + $extatual->setextent($ret->minx,$ret->miny,$ret->maxx,$ret->maxy); + } + else{ + $ret = explode(" ",$ret); + $extatual->setextent($ret[0],$ret[1],$ret[2],$ret[3]); + } +} +?> \ No newline at end of file -- libgit2 0.21.2