setProjection("init=epsg:4291");} if(isset($ext) && $ext != "") { $e = explode(" ",$ext); $extatual = $mapa->extent; $extatual->setextent((min($e[0],$e[2])),(min($e[1],$e[3])),(max($e[0],$e[2])),(max($e[1],$e[3]))); } if ($mapa->width > 500) { $mapa->setsize(500,500); } $of = $mapa->outputformat; $of->set("imagemode",MS_IMAGEMODE_RGB); $imgo = $mapa->draw(); if($imgo->imagepath == "") {echo "Erro IMAGEPATH vazio";exit;} $nome = ($imgo->imagepath).nomeRandomico().".png"; $nomefinal = ($imgo->imagepath).nomeRandomico().".wrl"; $imgo->saveImage($nome); $arquivocor = $nome; $numlayers = $mapa->numlayers; for ($i=0;$i < $numlayers;$i++) { $layer = $mapa->getlayer($i); $layer->set("status",MS_OFF); } if ($temaz=="") { $temastemp = $maptemp->getalllayernames(); foreach ($temastemp as $t) { $layer = $maptemp->getlayerbyname($t); $layer->set("status",MS_DEFAULT); ms_newLayerObj($mapa, $layer); } } else { $layer = $mapa->getlayerbyname($temaz); $layer->set("status",MS_DEFAULT); $eb=$mapa->scalebar; $eb->set("status",MS_OFF); } $cor = $mapa->imagecolor; $cor->setRGB(255,255,255); $imgo = $mapa->draw(); $nome = ($imgo->imagepath).nomeRandomico().".png"; $nomefinal = ($imgo->imagepath).nomeRandomico().".wrl"; $imgo->saveImage($nome); $arquivoalt = $nome; $imgcor = imagecreatefrompng($arquivocor); $imgcor = flipImage($imgcor, true, false); imagepng($imgcor,$arquivocor); $imgalt = imagecreatefrompng($arquivoalt); $sx = imagesx($imgalt); $sy = imagesy($imgalt); $fp = fopen($nomefinal,"w"); $texto = "#VRML V2.0 utf8 Group { children [DirectionalLight { direction 0 -1 0 } Shape { appearance Appearance { material Material { diffuseColor .2 .2 .2 }"; $texto .= "texture ImageTexture { url ".'"'.basename($arquivocor).'"'; $texto .= "} } geometry ElevationGrid { xDimension $sx xSpacing 1 zDimension $sy zSpacing 1 solid TRUE height [\n"; fwrite($fp,$texto); //fator redução de z if(($fz == "")||($fz == 0)){$fz = 1;} for ($y = 0; $y < $sy; $y++) { for ($x = 0; $x < $sx; $x++) { $alt = imagecolorat($imgalt, $x, $y); $z = ($alt >> 16) & 0xFF; fwrite($fp,($z/$fz)." "); //fwrite($fp,($alt)." "); } } $texto = '] } } ] } Viewpoint { position '.($sx / 2).' '.$sx.' '.($sx / 2).' orientation 1 0 0 -1.57 description "Above" } Viewpoint { position '.($sx / 2).' 1.000000 '.($sx / 2).' description "Center" } NavigationInfo { speed 100 type "EXAMINE" }'; fwrite($fp,$texto); fclose($fp); $h = "window.location.protocol+'//'+window.location.host+'/ms_tmp/".basename($imgurl)."/".(basename($nomefinal))."'"; echo "
O arquivo foi gerado!!
"; echo "
Clique aqui"; echo "

x:$x y:$y"; echo ""; function flipImage($image, $vertical, $horizontal) { $w = imagesx($image); $h = imagesy($image); if (!$vertical && !$horizontal) return $image; $flipped = imagecreatetruecolor($w, $h); if ($vertical) { for ($y=0; $y<$h; $y++) { imagecopy($flipped, $image, 0, $y, 0, $h - $y - 1, $w, 1); } } if ($horizontal) { if ($vertical) { $image = $flipped; $flipped = imagecreatetruecolor($w, $h); } for ($x=0; $x<$w; $x++) { imagecopy($flipped, $image, $x, 0, $w - $x - 1, 0, 1, $h); } } return $flipped; } ?>